Re: Autoboxing and Performance ?
Martin Gregorie <martin@address-in-sig.invalid> writes:
a Length should always have a units attribute
In OOP, we only model those aspects of entities of the
application domain we actually need.
When all agree upfront that within a certain project every
length is given in meters (double), we do not need to store
the unit with every value. Taking into account a run-time
unit for every value also makes calculations more complicated
(and thus possibly even more error-prone).
Moreover, a lenght (in physics) /does not have/ a unit!
(Just as a number does not have a number system.) Only the
/printed representation/ of a lenght has a unit, just as one
can print an integer in every number system one chooses.
For example, there is a certain distance from the sun to the
Procyon, what is the unit of that lenght? As a physical
value, it has no unit! Only when one wants to write it down,
one has to choose a certain unit system and number system,
and one can choose every unit system one likes. This is
an artefact of our notation, not a property of the length.