Monday, November 3, 2014

Of grey hairs and last leaves

Last week, I was teaching some old code new--or at least more sophisticated--tricks.   At one point, I tripped over a particular tactic that I thought I'd more or less "outgrown" by the time the code was originally written.  Every programmer who's been at a job long enough to replace the batteries in their cordless mouse knows this feeling.

Now, there was absolutely nothing wrong with the "old" code from either a functional or performance standpoint; it basically boiled down to style.  Alas, for all the wrong reasons--what future maintainers of this code might think heading the list--I "modernised" the syntax.  That's bad for two distinct reasons:

1.)  I'm basically lying to myself about myself.  I could write a whole blog about how not cringing at your old code is a sign that you've stagnated.  Doubtless, that's been done many times over.  So I won't.  (Though, for all I know, I already have.  I'm a little hazy on most of this blog's early history, truth be told.)

2.)  That change had to be tested to make sure I didn't introduce any errors or other unintended side effects into the code.   That wastes budget and time.

Don't get me wrong:  I believe in making code as easy as possible to skim.  That's no more than professional courtesy to future maintainers of that code...who will probably look an awful lot like a slightly greyer version of me.  Who, by the bye, should be old enough to appreciate what a little salt-and-pepper and laugh-lines around the eyes can add.  (Case in point--George Clooney.  A decade ago, I rolled my eyes at all the swooning. Now? Hawt.) In code, it's a signal that this isn't greenfield work; that's a valuable insight.

One more thought:  Trying to disguise the age of a code-base isn't doing newer programmers any favours, either.  The digital equivalent of a As-I-am-now-so-shall-you-be memento mori is good for perspective.  In our trade, that lesson's better internalised sooner than later.

And if I should live to be
The last leaf upon the tree
In the spring,
Let them smile, as I do now,
At the old forsaken bough
Where I cling.

- Oliver Wendell Holmes, Sr., The Last Leaf