Javier Eduardo Rojas Romero
April, 2020
The set of names, actions, and relationships used to model a system:
Technical people often feel the need to “shield” the business experts from the domain model…
§
If sophisticated domain experts don’t understand the model, there is something wrong with the model.
“If we give the Routing Service an origin, destination, and arrival time, it can look up the stops the cargo will have to make and, well … stick them in the database.”
§
“The origin, destination, and so on … it all feeds into the Routing Service, and we get back an Itinerary that has everything we need in it.”
§
“A Routing Service finds an Itinerary that satisfies a Route Specification.”
Well written code can be communicative, but the message it communicates is not guaranteed to be accurate.
It takes fastidiousness to write code that doesn’t just do the right thing but also says the right thing.
The model must guide the implementation
Results are abandoned soon after coding starts, and most of the ground has to be covered again
Design-while-implementing usually is rushed
Access to domain experts is difficult after implementation starts
The design must:
Revisit/refactor/rethink until you get both
Shows information to the user
Interprets user commands
Provides functionalities via domain objects
Thin, coordinates
This is what “User Stories” are all about
It’s the place for the business concepts, information, rules, etc.
Provides generic technical capabilities that support the higher layers.
Entities
Value Objects
Associations
Aggregates
Factories
Repositories
Services
Modules
Defined by their identity, not their attributes
Match objects with different attribute values but same identity
Are different from objects with the same attributes but different identity
Objects that describe things (what, not who)
Only their values are relevant.
Immutable*. They enable optimizations.
Boundaries between groups of one or more Entities/Value Objects
They have a root Entity/Value Object, and specify global/local scope for identities
Define scope of invariants/constraints, and transactionality (atomic/eventual consistency)
Complex object creation belongs to the Domain layer
But usually doesn’t belong into any specific Entity/Value Object/ Aggregate
Enter Factories
They provide the “illusion of an in-memory collection of all objects”
Provide access to root objects not easily reachable via Associations
Abstract the specific storage technology used
Don’t tuck everything into services. Not-so-fat-models are OK.
It is a truism that there should be low coupling between Modules and high cohesion between them.
There is a limit to how many things a person can think about at once (hence low coupling)
Incoherent fragments of ideas are as hard to understand as an undifferentiated soup of ideas (hence high cohesion)
Complexity: intellectual unmanageability
Yet, it isn’t just code being divided into Modules, but concepts