UOM models (units) of design

Looking for general principles for design patterns with respect to storing and converting known values ​​(i.e. meters to feet). Being googling was unlucky, so I must have something missing.

Assuming many fields with different UOMs in the same table are the best? Currently, many of the fields are implied, and we are looking at standardizing this. We want to give users the freedom to enter their UOM, and others to view it in their preferred UOM.

Do I have to store the "entered value" and convert it to some common primitive (the user enters the legs, I convert to counters and save this)? Should I store this entered stop value as an audit backup?

I am not the only consumer of any database table, is it better that in other applications the value is always indicated to the value + UOM and the raw user value.

Are there serious consequences for the conversion that I may lose. Meters> legs> meters should be reliable enough for conversion for a business application (conversions can be up to the 17th decimal place, but the displayed and entered values ​​are limited to 2-4 decimal places)

Any other thoughts or links to point me in the right direction so that I don't invent a solution to a known problem?

Please note that I do not expect some grandiose solution with operator overloading, but more than that which will work in a practical application that the average Joe developer can support.

+6
java design c # design-patterns design-principles
source share
4 answers

If you need a template following the UOM, JSR-275 (java) addresses. A popular library that implements JSR-275, JScience .

As for storing values, I would just create a column for value and measurement type (e.g. meter / feet, etc.) that never changes. Then the conversion can be easily done on request.

+2
source share

Take a look at the Template Analysis book. Also, review the Quantitative Template .

+1
source share

One option is to use a conversion table in the database. This will allow your users to enter measures in any way they want (measurement code + uom), and you can convert it on the fly at the exit.

I answered a similar question a while ago called SQL custom unit conversion

0
source share

Check out this Java API for units: http://www.unitsofmeasurement.org/

0
source share

All Articles