Build Your Functional Core

In this chapter, we showed how to build a functional core. It’s mostly datatypes and code made up of strictly functions in modules, with the same inputs producing the same outputs as often as you can. The functional core has no processes and invokes no external services. It encapsulates the bulk of the business logic.

We also built the functional core of our Mastery project. Along the way, we embraced some core programming principles.

  • Build single-purpose functions

  • Where possible, bring functions to data rather than bringing your data to functions.

  • Name concepts with functions

  • Shape functions for composition

  • Build functions at a single level of abstraction

  • Make decisions in function heads where possible

We’ll try to ...

Get Designing Elixir Systems With OTP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.