6: Value Objects
Often overshadowed by Entity-Think, Value Objects are a vital building block of DDD
Value types that measure, quantify, or describe things are easier to create, test, use, optimize, and maintain
Advantages
Value Types that measure, quantify, or describe things are easier to create, test, use, optimize, and maintain.
We should strive to model using Value Objects instead of Entities wherever possible.
Entity design should be biased towards serving as a Value container rather than a child Entity container.
How do we determine if a domain concept should be a Value Object?
When we care only about the attributes of an element in 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. Don't give it any identity and avoid the design complexities necessary to maintain Entities. [- Evans, p. 99]
Last updated