Part the first: The What
The end of the first month of the year brings many things. Fiscal closings, abandoned resolutions, ruminations on groundhogs… For us however, it brings another, more insidious creature: Inventory.
And so, once again, changes need to be made to rickety old code that gets dusted off once a year. I pop open the PHP code to make a change here or there only to feel my heart sink at this blight of bytes. Quickly rebounding, my heart races, and I feel the rush of the possibility, “Rewrite” I exclaim! Alas, there’s no time for that.
My hopes dashed, I take a second look at the code and decide all that’s possible, all that can be hoped for is to leave the code better than I found it. Not so hard, I’ll just put it under git, and start making changes.
Woah! Not so fast. The Debian Noid is here, and he says that libc6 is out of date, and the only way out is to upgrade the kernal.
Tinkering, tinkering, toiling and typing, I get the system to an unbootable state in record time. At one point, I lamented aloud that I was in bootloader hell. Shortly thereafter, I introduce said machine to the leather on the underside of my foot. We both win. The computer feels no pain, and I feel a measure of relief.
Luckily (or is it unluckily?) I backed up the code. The team handed me the keys to a shiny new server, and soon enough it was ready to code.
Part the second: The Where
“Where” as a concept has been forever altered by our series of tubes. This code. Does it live on a server? Does it summer in New Jersey? Or does it only fully live in memory, both virtual and physical? It also has a “where” temporally. It was written around 2004, tweaked a bit each year and now settled into it’s current desolation.
Where? Where should the 2009 version of me come in and get this piece of code ready to be put through it’s paces (and I mean that in the simplest way possible. No unit tests, no QA, just hard-working folks doing a dry run). The code goes into git. I start first with the crux of the app &ndash: the code that takes an item and logs it into the database.
Abstracting and centralizing the database calls, cleaning out impossible to reach code branches, Un-repeating myself… I come up for air and realize that the store closed half an hour ago, and I’m stuck inside with high-tech motion detectors ready to betray me. It’s the first time I’ve gotten into the flow state with code I’m this disgusted by.
Part the third: The Why
Why did I do this? What have I learned here?
I could have just done a search and replace to get this code runnable for the test and ultimately the actually inventory, but that felt wrong this time. Not just a little wrong like it has every other year, but deeply and uncomfortably wrong. Instead, I took the long, scenic route to arive at a place I’m a little less ashamed of. And that, that has made all the difference.