3 ms·
Today we'd talk about value objects[1], small objects that represent simple entities whose equality is not based on identity. Some languages include types to re
by cratermoon 4y ago
Today we'd talk about value objects[1], small objects that represent simple entities whose equality is not based on identity. Some languages include types to represent things other than numbers. Things like Timestamp and Duration. Most modern languages allow defining new types, which can be made immutable (barring language features like reflection that "go through the back door"). For example a Point that has x and y values assigned at creation and unchangeable. Any Point{x,y} is equal to any other Point{x,y} if x and y are the same, so there is no need for identity. In practice, the runtime may keep different instances of points, just as there may be two int values, i, and n, which are equal but stored in different memory locations.
1 https://martinfowler.com/bliki/ValueObject.html https://martinfowler.com/bliki/ValueObject.html