shlogg · Early preview
Cesar Aguirre @canro91

When To Use Value Objects Vs Primitive Values In Software Engineering

Not every primitive value deserves a Value Object. Use them when enforcing domain rules or performing business operations, otherwise stick with plain values.

I originally posted this post on my blog a long time ago in a galaxy far, far away.


Not every primitive value deserves to be promoted to a value object.
Some time ago, at a past job, I reviewed a pull request that triggered a discussion about when to use value objects instead of primitive values.
If you're not familiar with Domain-Driven Design and its artifacts:

  
  
  Value Objects Represents Concepts That Don't Have an Identifier

Value objects are immutable and compared by value.
Two value objects with the same values are considered the same. Two dates are the same if they point to the...