Superseded by Value Object Applicability v2.Use the Value Object pattern if
- the domain concept you are implementing represents a value type
and if
- the resulting class does not become too heavyweight as to slow down performance significantly.
We say that we implement “value objects” using a “value object class” that represents a “value type” as derived from modeling your application domain. Value type means the same as data type, but is more specific.
It would best if programming languages had language features that explicitly marked classes as value types, for ex-ample, by using the keyword “valuetype” rather than “class”. (This is finally in the making, see
IBM05,
SUN06.)
The Value Object pattern is widely applicable. Value types are as fundamental as object classes, making the distinction between values and objects explicit. Examples of value types in the financial services domain are monetary amounts and currencies, in the Internet domain they are protocol names, domain names, and URLs, in math they are percentages, explicit fractions, and integrals, and in engineering they are the metric system and its units.