Bindings, Platforms, and Innovation
This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.
Tracking change and innovation in the enterprise software development community
Posted by Geoffrey Wiseman on Oct 17, 2007 07:42 AM
JSR-275: Units Specification aims to add support for units to Java software development, with the hope of reducing a certain class of errors. As described by Jean-Marie Dautelle, co-spec-lead of JSR-275:Inadequate models of physical measurements can lead to significant programmatic errors. In particular, the practice of modeling a measure as a simple number with no regard to the units it represents creates fragile code. Another developer or another part of the code might misinterpret the number as representing a different unit of measurement. For example, it might be unclear whether a person's weight is expressed in pounds, kilograms, or stone. The issue is difficult to solve through testing and has already cost millions of dollars to society worldwide. (NASA lost a $125 million Mars orbiter because a Lockheed Martin engineering team used English units of measurement while the agency's team used the more conventional metric system for a key spacecraft operation.)
JSR-275 introduces a new package, javax.measure, with an interface, Measurable, and a class, Measure.
Measurable represents an attribute which could be measured which could be measured (e.g. Altitude, Height), and for which a value can be retrieved, given a compatible unit:
Measurable<length> height = person.getHeight();
long inches = height.longValue(NonSI.INCH);
By using generics, Measurable is typesafe; a compile-time error would be generated when passing Measurable<mass> to a function that requires Measurable<length>:
Measurable<mass> weight = person.getWeight();
person.setHeight( weight ); // error!
Measure represents a particular measurement, the combination of a numeric value and a particular unit. A particular measurable value (e.g. geoffreyWiseman.getHeight()) could be represented by different measures (e.g. Measure.valueOf(73,NonSI.INCH), Measure.valueOf(1.8542,SI.METRE)).
The API also contains quantities (e.g. Mass, Height, Power, Pressure), which are used to parameterize the generic measures and measurements, and Units (INCH, METRE), which are held within systems of units. SI represents the metric system, both with prefixes and units (METER, KILO(METER), etc.), and NonSI holds common units that aren't part of the metric system (DAY, FOOT, KNOT, etc.).
It's possible to convert between units of the same dimension using a UnitConverter. Parsing and formatting are accounted for, including compound units for combinations like feet and inches; hours, minutes and seconds. The API is designed for extension, supporting the creation of new units, systems of units, quantities.
There has been some discussion of using JSR-275 to support JSR-310, the date/time API, but there would need to be further discussion. Stephen Colebourne points out in JSR-275: Suitable for Java 7? that date/time units can't be treated like consistent scientific units for conversion:
Er, how exactly did we manage to convert between months and days? What does that really mean? Well, assuming I've understood everything, what it does is use a definition of a year as 365 days, 5 hours, 49 minutes, and 12 seconds, and a month being one twelth of that. It then goes ahead and does the conversion from months to days using that data.
To learn more, investigate the specification or the reference implementation.
Download the Free Adobe® Flex® Builder 3 Trial
Adobe® Rich Internet Application Project Portal
Adobe® Rich Internet Application Project Portal
Performance Management and Diagnostics in Distributed Java and .NET Applications
This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.
This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.
This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.
This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.
This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.
After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.
IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.
Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.
2 comments
Watch Thread Reply