Entity
Entities represent business objects that remain recognisable through state changes.
- IdentityThe order identifier connects its lifecycle.
- StateAttributes may change according to business rules.
- ComparisonMatching fields do not establish a shared identity.
Context
Why this is important
An order changes status. Its identity connects those states into one business transaction. Two orders with identical items remain two separate transactions.
Identity, lifecycle and behavior within a domain model.
At a glance · Identity persists
Same order, different state
Follow B-1042 from creation to confirmation. Then compare B-1042 with a hypothetical second order, B-1043: identical items do not make them the same order.
This is how you read the picture
- Identity B-1042 stays the same on both sides.
- State The status changes from created to confirmed.
- Comparison B-1043 remains a different order despite having the same items.
Order
Order IDB-1042 (comparison field)StatusCreatedItems2 mugs
Order
Order IDB-1042 (comparison field)StatusConfirmedItems2 mugs
same orderComparison of Identifier. The identifier is the same. The status may change in the life cycle, the order remains the same.
A monetary value needs a different comparison: amount and currency together.Explore value equality
One transaction over time
- 01
B-1042 · created
The order receives its identity and contains two mugs.
- 02
Payment authorised
Correlation links the payment response to order B-1042.
- 03
B-1042 · confirmed
The order status is updated. Its identity is preserved.
Benefits & limitations
Helps if:
- The object changes state while the business recognises it as the same thing.
- Relationships and history depend on a stable identity.
Boundaries
- A database key is a business identity only when the model uses it as such.
- Identity alone protects no invariants; that requires a responsible aggregate and valid operations.
In practice
- Identify how domain experts recognise an instance despite changing attributes. Validate its identifier and lifecycle together, and check whether equal-looking numbers really denote the same thing.
- Define permitted state transitions and place the Entity within an appropriate consistency boundary. Check whether relationships, history and business decisions depend on the same identity.
- Compare two objects with equal attributes but different identifiers. Document whether they remain distinct in business terms and which rules make that distinction visible in the model.
Read the detailed explanation
Identity is defined within its model context. It may be a business number, composite key or technical identifier if the context uses it as a durable identifier. Equal attributes do not imply the same entity.
Entity behavior keeps state changes valid in business terms. Aggregates place entities within a consistency boundary; an entity outside an aggregate is not automatically an independent transaction boundary.
Entities are managed within a consistency boundary such as an Aggregate; value-based data is represented by a Value Object.
Check your understanding
Test yourself in three stages
ReadingCheck in the picture
Which property remains stable for order B-1042?
View the solution with justification
Its order identity.
ApplyingTransferred to a new situation
Two orders have the same fields but different numbers. Same or different?
View the solution with justification
Different entities if the order number defines their identity.
EvaluateWeighing an alternative
Why is a database ID alone insufficient for the modeling decision?
View the solution with justification
The model must define whether and how that identifier expresses business identity.
Explore further
These building blocks continue the thoughts of this page.
References
- Eric Evans · DDD Reference (opens in new tab)Primary reference for entities and value objects.
- DDD Reference · German translation (opens in new tab)German edition of Eric Evans’ reference.
- Vaughn Vernon · Implementing Domain-Driven Design (opens in new tab)Covers tactical modeling building blocks through examples.