6 Implementing the Domain Model
This chapter covers
- Implementing the domain model
- Pure and impure Functions
- Designing around determinism
This chapter picks up where we left off in Chapter 5. We’ve modeled a complex invoicing domain. Now it's time to start writing code.
But we have to be careful.
A bad implementation can undermine a good data model. Methods in Java are often up to no good. They make us think about too much of our program at once and betray us with unexpected side-effects. We’re going to learn how to get them under control.
We’re also going to spend time learning how to organize our code. So far, our modeling has been purposefully indifferent to details like class ownership. We’ve focused only on the data and how it flowed through our program. But now we need to make architectural choices. Who should own these behaviors? Who can they talk to? Who can talk to them?
If you focus on the right properties, these questions will answer themselves.