Value object
A value object groups values whose combination and equality have business meaning.
- ComponentsAmount and currency form one business value.
- Value equalityAll relevant components match.
- Replacement valueA business change creates a new value.
Context
Why this is important
An amount without a currency is incomplete. A value object keeps related business data and rules together. A change is expressed as a new value; earlier values remain traceable.
Business value modeling without an independent object identity.
At a glance · Values determine equality
Same values, same monetary amount
The two mugs in B-1042 cost 49.90 EUR in total. Compare identical amounts, different currencies and matching address details. The USD variant is used only for comparison.
This is how you read the picture
- Components Both fields are highlighted as comparison fields.
- Value equality 49.90 EUR equals 49.90 EUR, but differs from 49.90 USD.
- Replacement value The comparison shows values; the timeline shows their replacement.
Monetary amount
Amount49.90 (comparison field)CurrencyEUR (comparison field)
Monetary amount
Amount49.90 (comparison field)CurrencyEUR (comparison field)
Same valueComparison of Values. The amount and the currency are the same. There is no separate identifier, so both amounts are interchangeable.
The order remains the same entity even if a contained value changes before confirmation.Follow identity over time
A new value replaces the old one
- 01
Original value · 49.90 EUR
Amount and currency are stored together.
- 02
Calculate discount · 44.90 EUR
The calculation creates a new valid monetary value.
- 03
Use the new value
The current calculation uses 44.90 EUR. The original value remains unchanged.
Benefits & limitations
Helps if:
- Primitive fields together form a meaningful unit or have their own rules.
- Value equality matches business comparison and is independent of storage identity.
Boundaries
- A value object is not automatically immutable everywhere; immutability is a design choice with clear benefits.
- Historical values must be retained when a change must not retroactively alter past transactions.
In practice
- Determine which values form one business unit and which combinations would be invalid. Group fields only when domain experts assign them shared meaning.
- Specify which fields determine value equality and which rules the value validates. State comparison so business logic and tests use the same definition of equality.
- Model a value change by replacing it with a new value and check whether completed orders must retain the confirmed state. Use a copy or version rather than silent mutation.
Read the detailed explanation
Value objects encapsulate rules for their values and are usually made immutable. Two instances with the same relevant values are equal in the model. A change creates a new value instead of silently mutating the same instance.
Equality follows the meaning of the model: amount and currency may form a value for money, while relevant address fields define an address. Aggregates determine which relationships and changes remain consistent.
A stable identity characterises an Entity; an Aggregate keeps related changes consistent.
Check your understanding
Test yourself in three stages
ReadingCheck in the picture
Why are 49.90 EUR and 49.90 USD different values?
View the solution with justification
Currency is part of value equality. Identical numbers with different currencies represent different monetary values.
ApplyingTransferred to a new situation
The customer changes address. How is the new value represented?
View the solution with justification
As a new value object replacing the previous address.
EvaluateWeighing an alternative
Why might a past order need its old address?
View the solution with justification
So that a change does not retroactively alter the historical transaction.
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.