Value Objects (Concept)
April 4, 2025 ยท View on GitHub
Description
An object in the domain model, which has no conceptional identity but are identified by their state. Value objects should be modelled as immutable.
Tags
pattern
Documentation
Some objects describe or compute some characteristics of a thing.
Many objects have no conceptual identity.
Tracking the identity of entities is essential, but attaching identity to other objects can hurt system performance, add analytical work, and muddle the model by making all objects look the same. Software design is a constant battle with complexity. We must make distinctions so that special handling is applied only where neccessary.
However, if we think of this category of objects as just the absence of identity, we havent added much to our toolbox or vocabulary. In fact, these objects have characteristics of their own, and their own significance in the model. These are objects that describe things.
Therefore,
When you care only about the attributes of an element of the model, classify it as a value object. Make it express the meaning of the attributes it conveys and give it related functionality. Treat the value object as immutable. Make all operations Side-effect-free Functions that don't depend on any mutable state. Don't give a value object any identity and avoid the design complexities neccessary to maintain entities.
Other Relations
| From | Name | To | Description |
|---|---|---|---|
| Value Objects | encapsulate with | Aggregates | |
| Value Objects | encapsulate with | Factories | |
| Model Driven Design | express state and computation with | Value Objects |
Concept Map

Concept Map of the Domain Driven Design Building Blocks Patterns
Navigation
(generated by Overarch with template docs/node.md.cmb)