2023-03-08 21:29:47

An immutable class whose identity is dependent on the combination of its values.


  • Value objects measure, quantify or describe a thing in the domain.
  • They are used as a property of an entity.
  • Identity is based on the composition of values.
  • Value objects are immutable and therefore should not have side effects.
  • Compared using all values
  • No side effects

Recognizing Commonly Used Value Objects

Currency at a point in time is a great value object.

For Example

Company worth: $US 50,000,000 on 2023-03-07 17:00:00

With this classic design it is possible to change the Worth Unit without changing to Worth Amount. Therefore significantly changing the worth of the company.

To fix this issue we use value objects.

The Unit and Amount have been exported into a Value Object. The value object is immutable. Meaning it must be replaced if any of its values are changed.

Copyright © 2024 delaney. All rights reserved.