Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Functional core, imperative shell

Liam McLennan
December 02, 2017

Functional core, imperative shell

Clean Architecture and Gary Bernhardt's functional core, imperative shell. They are all the same. This presentation will simplify and clarify an architecture that so many people have "discovered" independently. It is an architecture that decouples an application's core logic from the services it uses. It allows an application to be equally driven by users, programs, automated tests or batch scripts.

Liam McLennan

December 02, 2017
Tweet

More Decks by Liam McLennan

Other Decks in Programming

Transcript

  1. Good Bad Simple! Easy debugging …? No reuse No abstraction

    Algorithm hidden Refactoring difficult
  2. Badwords 1. Query a web page 2. Search for “bad

    words” 3. Rate the page on the number of bad words 4. Report the number of bad words to level up 5. Write the url to a text file, if the # of bad words is odd
  3. Keep logic and I/O separate Implement application logic in a

    pure functional core The core should have no external dependencies Define an application API (ports) to be used by all presentations (adapters) All dependencies point inwards towards the core Rules
  4. IoC and Mocking 1. Query that does not depend on

    an output of the computation 2. Query that does depend on the an output of the computation 3. Output
  5. Badwords 1. Query a web page 2. Search for “bad

    words” 3. Rate the page on the number of bad words 4. Report the number of bad words to level up 5. Write the url to a text file, if the # of bad words is odd
  6. Activity Home Fetching a URL from the terminal Core Shell

    Fetching content of a web page Find ‘bad words’ in content Calculate rating
  7. Fill out your feedback To go into the draw for

    prizes, please remember to complete your feedback at: http://www.dddbrisbane.com/feedback No feedback = No Prizes! #dddbne