DDD Building Blocks: Entities and Value Objects
Model the domain with rich entities and immutable value objects.
The tactical core
Domain-Driven Design's tactical patterns give you a vocabulary for modeling business concepts in code. The two foundational building blocks are Entities (objects defined by identity over time) and Value Objects (objects defined by their attributes and treated as immutable). Getting this distinction right shapes everything else in your domain layer.
Identity vs value
An Entity has a stable identity that persists even as its attributes change: a Customer is the same customer after they move house. A Value Object has no identity; two value objects with equal attributes are interchangeable, like two $5 bills. Ask: "if every field changes, is it still the same thing?" If yes, it's an entity.
All lessons in this course
- DDD Building Blocks: Entities and Value Objects
- Aggregates, Repositories and Factories
- Domain Events and Domain Services
- Bounded Contexts and Context Mapping