value-object


layout: pattern
title: Value Object
folder: value-object
permalink: /patterns/value-object/
categories: Creational
tags:

– Instantiation

Intent

Provide objects which follow value semantics rather than reference semantics.
This means value objects’ equality are not based on identity. Two value objects are
equal when they have the same value, not necessarily being the same object.

Class diagram

alt text

Applicability

Use the Value Object when

  • You need to measure the objects’ equality based on the objects’ value

Real world examples

Credits

粤ICP备15017284号