Units of measure are important in physics and engineering problems. Failure to include correct units can lead to lost credit or mission failures, as in the case of the Mars Climate Orbiter which was off in its trajectory by 170 km due to unit errors. Precise unit representation is needed to avoid ambiguities and allow for accurate calculations, as demonstrated in the example of converting between miles per hour and meters per second. Specialized libraries like Squants provide robust support for representing quantities and units to avoid issues.
2. “Numerical answers must have the correct units: The importance of units
cannot over over-emphasized... Failure to put the correct units, or any units at all,
next to your numerical answer will result in a loss of credit.”
Southern Methodist University Physics 3305 Homework Policy
3. “...the angular momentum (impulse) data
was in English, rather than metric, units,
resulted in 7 small errors being introduced in
the trajectory estimate over the course of the
9-month journey. At the time of Mars
insertion, the spacecraft trajectory was
approximately 170 kilometers lower than
planned.”
- Mars Climate Orbiter Mishap
Investigation Board Phase 1 Report
Mars Climate
Orbiter
9. Names are vague
Is this wet gallons? Dry gallons? US Gallons? Imperial Gallons?
10.
11. This is a code smell, specifically Primitive Obsession.
“Use of primitives instead of small objects for simple
tasks (such as currency, ranges, special strings for
phone numbers, etc.)”
12. Squants
“Squants is a framework of data types and a domain specific language (DSL) for representing
Quantities, their Units of Measure, and their Dimensional relationships. The API supports typesafe
dimensional analysis, improved domain models and more. All types are immutable and thread-safe.”
www.squants.com
13. A Tesla Model S accelerates from 0 to 60 mph in 4.2 seconds. Assuming
you floor the pedal how fast, in mph, are you travelling after 3 seconds?
14. A Tesla Model S accelerates from 0 to 60 mph in 4.2 seconds. Assuming
you floor the pedal how fast, in mph, are you travelling after 3 seconds?