Marcus Östling
Quantities and units in software models
Abstract
Quantities and units, while they are commonly used in science and engineering, they not at
all that common in software. The purpose of this thesis is to study how
quantities and units can be incorporated into software, and what the impact of
such an incorporation would be on the software's source code as well as its performance.
This was achieved by first designing a solution and implementing a proof-of-concept of
it. The proof-of-concept was used to evaluate the impact on the software and
compare it to the existing library UnitsNet as well as a solution using the primitive type
double. The design resulted in a statically typed solution and the impact on the source code was measured on two large codebases, 265k and 1138k lines of code.
The software metrics did barely showed any difference between the solutions,
but the opinion of asked developers showed that a statically typed solution
was preferred over a solution that used the primitive type double. The performance
tests showed that when the types were used in composite functions, it had the
same rate of growth as the solution using doubles had. But, the statically typed solutions
did increase the execution time by a constant factor. The constant factor could result
in ≈50 times slower execution time.