Code and Recode
Between 1999 and 2001, I wrote over 50,000 lines of code for data collection and data analysis. Well, we’re starting to look at getting some other values out of the dataset than what I originally extracted. And that means that I need to get back into the code I wrote to work out getting those new values.
Fortunately for me, I was writing code in Borland’s Delphi RAD tool. There’s a lot of code, but the IDE works nicely for navigating around it. Because it is in a Pascal-like language, it isn’t as obscure as C or C++ code left alone for several years. (There’s the old joke about C being a “write-only” language, implying that it was simpler to write any application over rather than try to get reacquainted with an already-written piece of code for modification.)
For instance, I was looking at some code that dealt with intranarial pressure values and thinking, “What exactly are my units?” But this is apparent by reference to the code:
genStringGrid.Cells[ord(crp_iip),ii+1] := format('%8.2f',[mpval]);
genStringGrid.Cells[ord(crp_iip_torr),ii+1] := format('%8.2f',[mpval*10.0]);
genStringGrid.Cells[ord(crp_iip_kpa),ii+1] := format('%8.2f',[mpval*10.0*torr2kpa]);
My original units were cm Hg, multiplied by 10 to get mm Hg or torr, and then multiplied by a conversion factor to get kilopascals.
Not everything is so clear in the code I’ve got, but it should be obvious that taking a little bit of time during coding to use meaningful names for variables and constants can pay some dividends down the road when trying to understand what is going on in the source code.