Value Object

Go to the Wiki Overview

  • In terms Domain-Driven Design, a Value Object is pure data. Two Value Objects with the same attributes are equal, and even identical. (Evans 2006, pp97–193)
    • This is a contrast to Entities which express identity not through their attributes, but by being a thing that persists over time.
    • In the sense of a programming language feature, Value Objects can be implemented as value types. If you know value types, you get the idea of Value Objects. (Only that Value Objects can actually be implemented as reference types with custom equality checks, like we used to do in Objective-C all the time where everything was an object.)

Classic example: Money or Date. The instances don’t matter, only the value.

Posts on the topic

Jan 18 2023

The Difference between Entity and Value Object, and How They Relate to Swift's Identifiable and Equatable Protocols

Nov 29 2022

Mutating Struct and State Observers: How the Latter Will Be Notified Even for 'No-Ops'

Mar 8 2019

Replacing More Reference Objects with Value Types

Jun 16 2018

Better Form Model Validation

Jun 6 2018

Validate Temporary Form Models

Jun 9 2016

Configuration Objects and the Then Microframework

Feb 1 2016

Always Write Functions to Cope with all Possible Parameter Values

Oct 16 2015

Achieve More with a Variety of Value Objects in Swift