Jeff said:
Hi Nick... A type safe unit library certainly does not replace
documentation and design requirements. But "to err is human" so IMHO
system solutions are a worthy goal. C# is type safe so we are all
_currently_ coding using type safety such as double or decimal or int. I
see no extra effort necessary to code using Meter, Grams and Celsius. In
fact, coding using Meter, Grams and Celsius is self documenting and
moves us toward the goal of self documenting code.
It definitely would be more effort to use temperature classes.
It is often much harder to understand a project which uses a number of
new Types to wrap normal more familiar type. Rather than follow the flow
of the code you need to take time out to investigate and understand the
new type. If you are putin a seat and asked to make a change to a
unknown large project the last thing you want is unnecessary complexity.
In this case it is also a bit heavy to have multiple classes why not
have one class which can be converted/from displayed as any of the other
temperature types. The four temperature types are equivalent the only
difference being the formatting and conversion from/to a double.
Redefining the FREEZE_H2O constants for each type is also a recipe for
disaster and may lead to inconsistency. A similar concept occurs with
DateTime where a locale is used to determine how UCT is displayed.
It may be that you have a project where the benefits of some kind of
type safety outweigh the drawbacks but I doubt it.
The SI unit of temperature is Kelvin I would need tremendously strong
reasons to allow anything else to be used.