Enhancing descriptiveness with value objects
Implementing Domain-Driven Design pointed out quite well that we should use value objects to measure, quantify, or describe things from our problem domain. For example, you can describe an ID attribute with a value object instead of a long or integer value. You can wrap a double or big decimal attribute into a specific value object to express quantification more clearly.
We're not fully satisfied with just using the built-in language types to model a problem domain. To make the system more explicit about its nature and purposes, we wrap those built-in language data types—and even our own created types—into well-defined value objects.
This effort to convey meaning is based on the following two fundamental characteristics about value objects:
- They are immutable.
- They don't have an identity.
Suppose you have painted a picture. Imagine how strange would it be if, for some reason, after you&apos...