Under the Hood

Working two jobs eased out a lot of my prior free time in the evenings. I stopped playing WoW (at least until the next expansion), and I’ve had less time to work on my major hobby, which is currently Anthropomotron. It is not surprising then that I have made additions at a slow but consistent pace. I did kick into a higher gear when I noticed during some copying and pasting of code that in certain cases, the kilogram to pound conversion made no sense. I fixed it and rushed out the 1.5.1 update before anyone else noticed and/or told me about it.

In the week between my online courses, I had the previous breadth of free time. I got into a new game (Marvel Heroes, which is basically free Diablo with comic characters). More importantly I cranked out several major changes to Anthropomotron for a future update. Stature estimation received a new category: estimation of juvenile stature from limb bone length via two different team’s research (Ruff [2007] and Robbins Schug et al. [2013]).

The new section runs on a new set of code. In the older formulae, there are multiple copies ofthe same mathematical functions. For example, adult stature estimation with one long bone has code to perform a calculation with a linear regression formula with the right values plugged in. Body mass estimation using the femoral head diameter has its own section of code to perform a calculation with a linear regression formula with its own values. The same duplication appears for other processes, such as converting centimeters to feet and inches, and displaying the result on screen. The code works, but it is not elegant.

Juvenile stature estimation is written differently. I wrote a single linear regression formula function that will now handle all requests for this calcuaiton. Whether one uses the Ruff or Robbins Schug and colleagues method, the specific values are passed to this one function, which hands back the calculated result for further processing. I also wrote single functions for unit conversion and the display of the result, like an assembly line of steps. The benefits of coding this way are that the code is shorter and there are fewer chances for error with duplicated code (for example, miscalculating kilograms to pounds in some occasions).

Over time, I plan to transition the old code to use the new functions, making the whole thing even more efficient. Elegant, even, as programmers say. Stay tuned for the 1.6 release with the juvenile stature estimation and a little something extra, possibly detailed in an upcoming blog post!

1 thought on “Under the Hood

Leave a Reply

Your email address will not be published. Required fields are marked *