Legacy Issue Number: 17053
Source: SimVentions ( Matthew Wilson)
Using this as an object rather than a plain double value is a cheap way to avoid costly errors. NASA lost a $125 million Mars orbiter because one team was using imperial units instead of metric. Representing distance as an object makes it glaringly obvious in the code which calculations are using which units.
Consider the following method of Rectangle:
Embedded in the comments of the interface contract is that “getHeight()” returns a double in meters. But that’s not at all obvious in client code that uses getHeight(), especially if it’s 2 or 3 levels removed from the place it is called.
Instead, if it were changed to:
Distance could have methods “double getMeters()”, and “double getFeet()”, that make it immediately obvious what the returned value represents.
If adopted, the following changes should be made:
o Change altitude property from double to Distance
o Change getHeight() to return Distance
o Change getWidth() to return Distance
o Change getRadius() to return Distance
o Change get/setRangeScale to use Distance
o Change scaleToPoints(points, margin) margin parameter to Distance
A Distance class has been added to the specification and referenced in the places suggested.
STILL NEED TO IMPLEMENT THIS IN THE SPEC.
Reported: TCI 1.0b2 — Thu, 26 Jan 2012 05:00 GMT
Updated: Wed, 1 Feb 2023 21:57 GMT