K.Value Object

  1. Motivation

      1. To create a small simple object, like money or a date range, whose equality isn't based on identity.

  2. Summary

      1. Value Object is usually the smaller; it's similar to the primitive types present in many languages that aren't purely object-oriented.

      2. The key difference between reference and value objects lies in how they deal with equality. A reference object uses identity as the basis for equality

  1. When to Use

      1. Treat something as a Value Object when you're basing equality on something other than an identity. It's worth considering this for any small object that's easy to create.

  1. Overview Tutorials

  1. Implementation

      1. .NET has a first-class treatment of Value Object. In C# an object is marked as a Value Object by declaring it as a struct instead as a class.

      2. The environment then treats it with value semantics.

  1. Example

      1. Money or Date Range object

  1. Related Patterns

    1. Data Transfer Object : are some time treated as Value Object.

    2. Embedded Value

    3. Serialized LOB

  1. Related Technologies

      1. None

  1. References

      1. None