Can you hide the units?

Contact us

Can you hide the units?

Fill out form to continue
All fields required.
Enter your info once to access all resources.
By submitting this form, you agree to Expero’s Privacy Policy.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

In the kind of programming we do — scientific simulations and decision support — modeling is usually the first task, and often the hardest. Structuring your problem the right way can make all the difference in determining whether future code is graceful or spaghetti-like.

I’ve been unconsciously using an approach recently which seems worth noting. I’ve been trying to get rid of units of measure in our models. You know, those pesky things that often go assumed or, worse, undefined, in a lot of systems. Meters? Feet? US Survey feet? Arbitrary but consistent measures of length? If representing feet in a domain event, then is “ft” good enough? Or should you use“urn:ogc:def:uom:UCUM:[ft_us]“? For many key attributes, you can’t escape saying what’s what.

But it seems like in many cases you can pull a fast one and make the units disappear from your model, so you’re more immune to changes in representation. How? By following the same rule that journalists should follow when they quote units: divide them by other units. For instance, would you be impressed or unimpressed that about 27 million people were added to the US population between the 2000 and 2010 census? I’m not entirely sure I know either. But if I told you that was a 9.7% increase in 10 years, you’d be better off.

If we can reduce our inputs to a unitless fraction — ratios —  then we do. A recent example involved storing the viewport size for a persisted visualization session. We could have saved something like “1600×1200″ and had people guess it was pixels. We could report a click in the middle of the screen as coming in at “800×600″. But then when that session was rejoined on another machine and the poor user was on projector which only supported a screen which was 1024 pixels wide, then we’d have to recalculate his viewport to be something like “1024×768″ and report that center point as coming in at “512×384″. The math you’re doing in your head there is already dealing with ratios instead of numbers. That aspect ratio is 4:3, and that center point is (0.5×0.5). This way we’re ready to display our scene on any sized screen.

The dimensional analysis doesn’t always work out this way, but where we can get away with it, we’ve been pleased.

Where can you hide your units?

User Audience

Services & capabilities

Project Details

Technologies

Sebastian Good

January 30, 2012

Can you hide the units?

Tags:

In the kind of programming we do — scientific simulations and decision support — modeling is usually the first task, and often the hardest. Structuring your problem the right way can make all the difference in determining whether future code is graceful or spaghetti-like.

I’ve been unconsciously using an approach recently which seems worth noting. I’ve been trying to get rid of units of measure in our models. You know, those pesky things that often go assumed or, worse, undefined, in a lot of systems. Meters? Feet? US Survey feet? Arbitrary but consistent measures of length? If representing feet in a domain event, then is “ft” good enough? Or should you use“urn:ogc:def:uom:UCUM:[ft_us]“? For many key attributes, you can’t escape saying what’s what.

But it seems like in many cases you can pull a fast one and make the units disappear from your model, so you’re more immune to changes in representation. How? By following the same rule that journalists should follow when they quote units: divide them by other units. For instance, would you be impressed or unimpressed that about 27 million people were added to the US population between the 2000 and 2010 census? I’m not entirely sure I know either. But if I told you that was a 9.7% increase in 10 years, you’d be better off.

If we can reduce our inputs to a unitless fraction — ratios —  then we do. A recent example involved storing the viewport size for a persisted visualization session. We could have saved something like “1600×1200″ and had people guess it was pixels. We could report a click in the middle of the screen as coming in at “800×600″. But then when that session was rejoined on another machine and the poor user was on projector which only supported a screen which was 1024 pixels wide, then we’d have to recalculate his viewport to be something like “1024×768″ and report that center point as coming in at “512×384″. The math you’re doing in your head there is already dealing with ratios instead of numbers. That aspect ratio is 4:3, and that center point is (0.5×0.5). This way we’re ready to display our scene on any sized screen.

The dimensional analysis doesn’t always work out this way, but where we can get away with it, we’ve been pleased.

Where can you hide your units?

User Audience

Services

Project Details

Similar Resources

Serverless ML

You can now deploy your models and get real-time scalable results without ever having to provision a server. Let me show you how I did it.

Watch Demo

Software Craftsmanship in Context

Software quality matters. Learn from a real use-case how we follow the Software Craftsmanship method to push a hard project forward.

Watch Demo

Company for a Cup of Joe: Finding Your Tribe

Combining traditional search techniques with graph algorithms to efficiently find subgroups within data.

Watch Demo

Testing React Applications Using Jest and React Testing Library

Avoid bugs & gain confidence when refactoring code by writing tests for your React code using Jest, React Testing Library & a Test Driven Development approach.

Watch Demo