You may have heard it said that โAll code is legacy code.โ Itโs a useful guiding principle โ and truer than we want to admit.
If all code is legacy code, then we are all maintainers.ย I carry an image in my head of a vast sea of silent, diligent, dedicated coders who stoically maintain much of the code that makes the world go round.ย I carry this image because I am one of those coders.ย
For the better part of the last 15 years, I have either directly maintained 30-year-old code or managed developers who did.ย And I donโt think Iโm alone.ย I figure for every developer discussing cutting-edge topics on Hacker News, there are seven or eight of us out there, quietly grinding away at keeping that inventory system running on the current version of Windows, despite large chunks of the running code having originally been written in Turbo Pascal 3.0 in 1987.ย
It is often said, โThe worst programmer I know is me six months ago.โย But I know a programmer worse than that โ the developer (maybe it was me) who wrote that code from 37 years ago.
I have spent a serious amount of time trying to decipher what that person did. What in the world were they thinking?ย Who thought that 13 nested if statements were a good idea?ย Who decided that five interlocking boolean conditions should go into the fourth nesting of those statements?ย Hadnโt they heard of an explaining variable?ย What the heck does the literal value 4 mean here?ย 9280 lines is a bit much for a single procedure, donโt you think?
So Iย shake my head, puzzle it out, and fix that bug.ย Or I wedge a new feature into that thousands-of-lines-of-code procedure.ย And I marvel that the code still runs, still (mostly) works, and still lives on.ย
Sure, we all laugh at the crazy stuff developers did back then.ย But it occurs to me that a little humility is in order.ย To our modern eye, which has the benefit of the wisdom of the past few decades, that code looks terrible.ย But maybe we just didnโt know any better back then.
Standing on spaghetti
At the time, the tools casually encouraged you to write code that today makes us cringe.ย Much of the code we maintain came from the โonClickโ era.ย Back in the 1990s, โrapid application developmentโ (RAD) was all the rage, and it practically begged us to tightly couple our business logic to our user interface.ย Double-click on the button and start coding!ย What could be better?
Back then we were all worried that our administrative assistants were going to use these RAD tools to put us developers out of business.ย Today we worry that it will be AI.ย I donโt even want to think what the next thing will be that will allegedly put skilled developers out to pasture.ย (Iโm not a believer that it will ever happen, but that doesnโt stop pundits from scaremongering.)
My awkward dance with Turbo Pascal ought to remind us that the code we write today will likely be viewed in exactly the same way by some developer (maybe it will be you) 37 years from now.ย ย
Our profession grows and improves, and we find better ways to do things.ย We stand on the shoulders of giants.ย Software engineers like Martin Fowler, Robert C. โUncle Bobโ Martin, Kent Beck, Michael Feathers, and Grady Booch all noticed โ and then codified โ practices we all take for granted today.
For instance, object-oriented programming (OOP) revolutionized the way we write code.ย Yet today, the way we do OOP is vastly different from the way we did even 10 or 15 years ago.ย
We wrote a lot of OOP code and eventually figured out principles like โPrefer composition over inheritanceโ and โEncapsulation is the most important pillar.โ It was through hard-won experience that Uncle Bob Martin developed the SOLID principles in 2000.ย ย
Beck didnโt start teaching us to write better code through test-driven development until the early 2000s. Fowler didnโt introduce the term โdependency injectionโ until 2004.ย Even today people donโt code against abstractions enough.ย There was a lot of coupled, multiple-responsibility, abstract code written before these folks and others saw better ways, and yet we still argue over whether they are right and whether these practices do indeed make our code better.ย
What goes around
So that takes me back to the current situation. I have to confess that for many years, Iโd whine and complain about the code I work with.ย Iโd shake my head in wonder and ask how anyone could write such crappy code.ย Iโd think that it all needs to be rewritten and how could this possibly work anyway?
But at some point, Iโd come to realize that it does work. It actually works out there on customersโ machines in the wild.ย And I decided that I respected that.ย Sure, fixing things takes more time than Iโd like, and adding features can often reinforce the โbadโ coding practices, but working code is the ultimate goal, right?ย And if it works todayโฆ?
There is a strong temptation to say โWe need to rewrite this to make it better,โ and maybe that is the better long-term solution.ย Itโs often hard to say.ย But for the โvintageโ code out there, maybe โfixing bugs and making it work correctly no matter whatโ is kind of a form of โbetter.โ Sometimes the right thing to do is just fix the bug and add 10 more lines of code to that 1500-line procedure.
So as I work through some code that makes little sense to the modern eye, I try to remember that when that code was written, it was probably cool and innovative and exciting.ย The person who wrote it was doing their best with what they had and what they knew.ย
And I try to remember that there is definitely some eight-year-old kid out there who one day will look at the new, modern, and cool code I write today and shake her head in wonder and mild disgust, asking โHow could he have possibly written that?โ
So maybe the worst programmer I know is me, right now.


