units of measure : Java Glossary

units of measure
One of the most common errors in engineering programming is making invalid assumptions about the units of measure of a variable. Is the force measured in newtons or pounds? If the units of measure were explicitly stated, then dimensionality consistency checks could automatically be done on assignment and expressions. You can’t assign a variable measured in kiloPascals to one measured in joules. You can’t add seconds to kilograms. The compiler could even put in conversion factors when the units don’t quite match, so long as the dimensionality is correct, e. g. assign a miles/hour value to a km/hour variable, or perhaps even a miles/gallon value to a liters/km variable.

What is dimensionality? You can think of any unit of measure as distanced x massm x timet for some positive or negative integers d, m and t. For example speed = distance × time-1. The dimensionality of a unit of measure is that tuple: d, m and t.

The same notion can apply to units of measure in business programming, e.g. does variable size measure rows or columns? It is dangerous to get it backwards. If the units of measure were formally declared, the compiler could catch you if you used the variable in the wrong context.

Some people have suggested piggybacking a scheme for checking units of measure atop Java. Others want to go further and have automatic conversions applied.


CMP homejump to top

available on the web at:

http://mindprod.com/jgloss/unitsofmeasure.html
  

optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\unitsofmeasure.html
logo
Please email your , letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email. If you want your message, your name or email kept confidential, not considered for public posting, please explicitly specify that. Unless you state otherwise, I will treat your message as a letter to the editor that I may or may not publish in the feedback section. After that, it will be too late to retract it. If you disagree with something I said, especially when sending an ad-hominem attack, a rant composed mainly of obscenities or a death threat, please quote the offending passage and cite the web page where you found it, tell me why you think it is wrong, and, if possible, provide some supporting evidence. I can’t very well fix erroneous or ambiguous text if I can’t find it.
Blog
IP:[65.110.21.43]
Your face IP:[54.234.126.92]
You are visitor number 12,661.