What are entities, value objects and aggregates in DDD, and how do you draw aggregate boundaries?
Short answer
An entity has identity (equal when the id is equal); a value object is equal when all its values are equal and should be immutable. An aggregate is a cluster of entities and value objects guarded by an aggregate root: every change goes through the root.
3 points to say:
- Entities are equal when the id is equal; value objects when all values are equal, and should be immutable (
Money,Address). - An aggregate is a cluster with a root and a consistency boundary; every change goes through the root.
- One transaction changes one aggregate; keep aggregates small, refer to others by id, eventual consistency between them.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.