Boost logo

Boost :

From: Michael Fawcett (michael.fawcett_at_[hidden])
Date: 2007-01-22 14:37:06


On 1/22/07, Noah Roberts <roberts.noah_at_[hidden]> wrote:
> Yes, it does sound familiar but it is just a common way of writing bad
> code. In any given project your base unit should be the same for any
> given function. Anything that accepts a length should accept either
> feet or meters, and a mix of both in your project is a Really Bad Thing.

And how can you enforce this? Take for instance a database that holds
radar characteristics. The units that pilots use are always feet (for
altitude) and nautical miles (for distances). Ground elevation data
is stored as DTED files which are in meters, where the distance
between elevation postings is in latitude/longitude. Now convert an
AGL (Above Ground Level) altitude to an MSL (Mean Sea Level) altitude.
 Wait...that requires adding feet (the altitude of the aircraft is
always given in feet) to the ground elevation at that particular
latitude/longitude (but wait, pilots measure distance in nautical
miles, plus the ground elevation is given in meters!). These are all
just errors waiting to happen that a good units library will catch at
compile-time.

> Really the only thing this static unit library provides is a way to
> enforce a policy of base units. This is a good thing but is rather
> incomplete without a way to interact with the user, who will want
> his/her display and entry in different unit formats.

I don't see how this library prevents a program from doing just that,
albeit from a limited set of different units, but surely it had to be
limited anyways to give them a set of options to choose from?

--Michael Fawcett


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk