Data Types - silverlain/IT-0-Machines GitHub Wiki

[August 2016] Value Object

A small object that represents a simple identity (ex. date range, money, name) whose equality is not based on identity (equal based on values of their fields, not being the same object reference). Value objects should be immutable, since two value objects created equal should remain equal. Value objects may also be immutable to prevent them from being put in an invalid state. In summary, objects are mutable while value objects are immutable, and objects are referenced (obj1=obj2 assigns obj1 a reference to obj2) while value objects are copied by value (valobj1=valobj2 makes a copy of the attributes of valobj2 to valobj1). Native support in C#, emulated in Java by making object immutable (since if state of object does not change, passing reference is semantically equivalent to copying value object).