Chapter 1. Functional domain modeling: an introduction


This chapter covers

  • Domain models and domain-driven design
  • Benefits of functional and pure domain models
  • Reactive modeling for increased responsiveness
  • How functional meets reactive

Suppose you’re using the portal of a large online retail store to make purchases. After entering all the items, the shopping cart fails to register your purchases. How does that make you feel? Or say you do a price check on an item a week before Christmas, and the response comes back after an inordinate delay; do you like this shopping experience? In both cases, the applications weren’t responsive. The first case depicts a lack of responsiveness to failure—your whole shopping cart went down because a back-end resource wasn’t available. The second case illustrates a lack of responsiveness to varying load. Maybe it’s the festive season that has triggered excessive load on the system and made your query response too slow. Both cases result in extreme frustration on the part of the user.

For any application that you develop, the core concept is the domain model, which is the representation of how the business works. For a banking system, the system functionalities consist of entities such as banks, accounts, currency, transactions, and reporting that work together to deliver a good banking experience to the user. And it’s the responsibility of the model to ensure that users have a good experience when they use the system.

1.1. What is a domain model?

1.2. Introducing domain-driven design

1.3. Thinking functionally

1.4. Managing side effects

1.5. Virtues of pure model elements

1.6. Reactive domain models

1.7. Event-driven programming

1.8. Functional meets reactive

1.9. Summary