7. 7
Mars
Climate
Orbiter
“The problem here was not the error; it was the
failure of NASA's systems engineering, and the
checks and balances in our processes, to detect
the error. That's why we lost the spacecraft.”
—Edward Weiler,
NASA associate administrator for space science,
IEEE Spectrum: Why the Mars Probe went off
course
8. Other Unit
Mishaps
8
● The 12 October 1492 “mishap”
● “Gimli Glider”, 1983
○ Air Canada Flight 143
○ Received less than half the fuel
needed
● Clarence the Tortoise, 2001
● A whole set of medication dose
errors
10. What Is the Fundamental Problem?
10
Primitive (Java) types
are primitive types
11. What Is the Fundamental Problem?
11
● Primitive (Java) types are primitive types
○ As in: building blocks to build other types
● Examples fundamentally in conflict with OOP and DDD:
○ static final double C = 1079252849;
○ static final double SPEED_OF_LIGHT = 1079252849;
○ static final double SPEED_OF_LIGHT_IN_KM_PER_H = 1079252849;
● What it should be:
○ static final Quantity<Speed> SPEED_OF_LIGHT
= Quantities.getQuantity(1079252849, Units.KILOMETRE_PER_HOUR);
12. Rolling Your Own Library
12
● A lot of work
○ Development
○ Maintenance
○ Upgrades and extensions
● Error-prone
● Are you a units of measurement domain expert?
○ Even of the units of measurement system you’re used to?
14. JSR 385: Units of Measurement API 2.0
14
Description:
This JSR is a major evolution of the Unit API 1.0 (JSR 363) specification.
Focused on the SI System redefinition, modularity and support for Java SE
8/9 and above.
JSR 363: Units of Measurement API
This JSR specifies Java packages for modeling and working with
measurement values, quantities and their corresponding units.
18. Definition of a Physical Quantity
18
“A physical quantity is a physical property of a phenomenon, body, or
substance, that can be quantified by measurement.”
Source: Wikipedia
19. Definition of a Physical Quantity
19
“A physical quantity is a physical property of a phenomenon, body, or
substance, that can be quantified by measurement.”
Source: Wikipedia
“A physical quantity can be expressed as the combination of a magnitude
expressed by a number – usually a real number – and a unit.”
Ibidem
21. Definition of a Physical Quantity
21
“A physical quantity is a physical property of a phenomenon, body, or
substance, that can be quantified by measurement.”
Source: Wikipedia
“A physical quantity can be expressed as the combination of a magnitude
expressed by a number – usually a real number – and a unit.”
“The same physical quantity can be represented equivalently in many unit
systems.”
37. Question: How Much is 0 °C + 0 °C?
● 0 °C
● 0 °C
● 273.15 °C
Two absolute temperatures:
0 °C + 0 °C = 273.15 K + 273.15 K
= 546.30 K
= 273.15 °C 37
38. Question: How Much is 0 °C + 0 °C?
● 0 °C
● 0 °C
● 273.15 °C
An absolute temperature and a temperature change:
0 °C + 0 °C = 273.15 K + 0 K
= 273.15 K
= 0 °C 38
39. Question: How Much is 0 °C + 0 °C?
● 0 °C
● 0 °C
● 273.15 °C
Two temperature changes:
0 °C + 0 °C = 0 K + 0 K
= 0 K
= 0 °C 39
40. Question: How Much is 0 °C + 0 °C?
273.15 °C (546.30 K)
0 °C + 0 °C = 0 °C (273.15 K)
0 °C (0 K)
40
41. Multiplication
41
Units:
● kg × m = kg·m
● kg × mm = kg·mm
● g × km = g·km ≟ kg·m
● m × m = m2
● km × km = km2
● mm × km = mm·km ≟ m2
● µm × m = µm·m ≟ mm2
Quantities:
● 2 kg × 3 m = 6 kg·m
42. Division
42
Units:
● kg / m = kg·m-1
● kg / mm = kg·mm-1
● g / mm = g·mm-1 ≟ kg·m-1
● m2 / m = m
● m / m = 1
● km / km = 1
● km / m = km/m ≟ 1k
Quantities:
● 3 kg / 2 m = 1.5 kg·m-1
48. Systems of Unit
48
● Metric system
○ Metre, kilogram, second, ampere, …
● Imperial system
○ Foot, ounce, pound, gallon, Fahrenheit, horsepower, …
● United States customary units
○ Foot, ounce, pound, gallon, Fahrenheit, gallon, …
● Roman units of measurement
○ Pes, uncia, libra, …
● Norwegian units of measurement
○ Fot, favn, mål, tønne, snes, …
54. The Java Community Process
54
“The JCP gives you a chance to have your own work become an official
component of the Java platform and to offer suggestions for improving and
growing the technology. Either way, everyone in the Java community benefits
from your participation. That's one of the reasons the JCP is open to everyone.”
Source: https://www.jcp.org/en/participation/overview
55. Becoming a JCP Member
55
“Membership in the JCP offers you a chance to become a permanent part of
the Java platform's history by contributing your work and recommendations to
the various standard specifications, and/or a chance of serving on the
Executive Committee.”
Source: https://www.jcp.org/en/participation/membership