4. Building blocks
Entity
Value object
Aggregate
Aggregate root
Service
Repository
Unit of work
Factory
5. Entities vs.
Value objects
Entity is not defined by its attributes, but rather by a thread of
continuity and its identity.
Value object contains attributes but has no conceptual identity.
They should be treated as immutable.
6. Aggregate
root
An aggregate root is an entity that composes other entities (as
well as its own values) by composition. If an entity has a reference
to another entity, then the referenced entity must either be within
the same aggregate, or be the root of some other aggregate.
An aggregate root is responsible for ensuring that the aggregated
entities are always in a valid state.
7. Creating
domain
objects
Objects that describe the system
Should be clean, well organised and testable
Technology that must fit the domain objects, not vice versa.
Void of persistence related code making them technology
agnostic or persistence ignorant.
Should be plain old objects and void of any technology related
attributes.
8. Repository
A repository is an abstraction over the persistence store, returning
entities – or more precisely aggregate roots – meeting some
criteria.
9. Unit of work
Maintains a list of objects affected by a business transaction and
coordinates the writing out of changes and the resolution of
concurrency problems.
10. Services
Infrastructure services
Cross-cutting services that you put into the Infrastructure layer:
logging, emailing, caching etc.
Domain services
Holds a behaviour that does not belong to any other entity or value-
object in the domain
Application services
Interface used by the outside world to use the domain
11. Factories
Contains methods for creating domain objects so that alternative
implementations may be easily interchanged.