TCI 1.1 RTF Avatar
  1. OMG Issue

TCI11 — Add a Distance Class to the Standard

  • Key: TCI11-31
  • Legacy Issue Number: 17005
  • Status: open  
  • Source: SimVentions ( Mr. Matthew Wilson)
  • Summary:

    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:
    double getHeight();

    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 getHeight();

    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:
    • GeodeticPosition
    o Change altitude property from double to Distance
    • Rectangle
    o Change getHeight() to return Distance
    o Change getWidth() to return Distance
    • Circle
    o Change getRadius() to return Distance
    • ViewEyeProperties
    o Change get/setRangeScale to use Distance
    • Viewport
    o Change scaleToPoints(points, margin) margin parameter to Distance

  • Reported: TCI 1.0b2 — Thu, 19 Jan 2012 05:00 GMT
  • Updated: Wed, 1 Feb 2023 21:57 GMT