Tag: Value-Objects
Objects That Don't Deserve an ID: Using Rails composed_of
In the real world (and in code), there are entities that sit somewhere between a plain scalar and a full-fledged object. What do things like 80 kilograms, 25 kilometers per hour, or 25×25×50 cm really mean? They’re clearly not scalars in the strict sense—they can’t be reduced to a single value like 25 or “Buenos Aires”. But they also share a key trait with scalars: they don’t exist on their own in reality. 80 kilograms describes the weight of something, just as 25 km/h represents the speed of something. Dimensions describe a box, a piece of furniture, or a piano—but mean little on their own.