Zen and the Art of Legacy Web App Maintenance
Before we jump into the nerdy bits here, let’s take a moment to honor the true thinker of Zen, author Robert M. Pirsig, who passed away April 24th, 2017.
Quality . . . you know what it is, yet you don’t know what it is. But that’s self-contradictory. But some things are better than others, that is, they have more quality. But when you try to say what the quality is, apart from the things that have it, it all goes poof!
— Robert M. Pirsig, Zen and the Art of Motorcycle Maintenance
We make a lot of websites and web apps here at Viget. And since we don’t like to hand off our work and tell clients to get lost, we’ve found ourselves maintaining a decent amount of large codebases over the years. While the mere uttering of the words “legacy code” can send developers running for the hills, I’ve often found this work to be satisfying and meaningful in various ways.
Open Your Mind, Enhance Your Calm
I’ve had the privilege of running point on a handful of fairly large maintenance projects over the last few years, and I find that my sanity in those situations relies heavily on the mindset I work within. While there are many things to easily point at and complain about when working with old codebases, focusing on those is a surefire way to drive yourself into a pit of self pitying not-fun-times. And really, it’s not that hard to find a bunch of really nice things about maintenance work to think about instead. For example:
I Know the Codebase Like the Back of My Hand
Similar to the back of my hand, I don’t spend my waking hours studying the finer details of legacy codebases. But when I do need to dive in to a particularly remote section of code, it’s like visiting an old friend. And for portions of the codebase that I do regularly work within, there’s no one on this planet who can debug, execute updates, and deploy fixes as quickly as I can. A definitively good feeling.
The Chance to Cultivate a Good Longterm Relationship with Decision Makers
As a consultant that sees projects come and go regularly, it’s not often that this opportunity presents itself. And while working with actual real life people may not be a developer’s idea of a good time, this has been the basis for some of my most notable professional growth over the years.
New Feature Requests are an Interesting Challenge
So a new request comes in to make X look like this other super hot thing the client found on the InternetIsBeautiful subreddit. You know how you would execute this request if you had a blank page to work with, but instead you have the opposite. A living breathing code organism that can’t go down and also can’t use that awesome new library that just rolled out. Balancing the desire to pull in more modern technologies with the efficacy of existing entrenched code has all the challenges a problem solving loving developer could hope for.
Level Up Your Technology Skills
While your days or weeks spent running a maintenance project could be filled executing mind numbing tasks, odds are that something pretty challenging is going to come across your plate every now and then. Be it a new feature that you have to work into an existing system, or a deprecation of a critical component of your application, there are always things to be learned from an old codebase.
You Are One with the Source Code
Using an open source library that is now 5 major versions behind today’s bleeding edge? Can’t find applicable documentation because the stone tablet on which it was carved has eroded (or something like that?) Time to get comfortable digging around some source code. Sometimes fun, sometimes confusing, sometimes unbelievably confusing. It’s an activity that becomes more valuable over time however and opens your eyes to a variety of programing styles and tactics.
A First Hand Look at All Your “Great” Ideas
Developers have a lot of opinions about the right way to do things. Many ideas are good, many more are disproportionately hyped. How can you be sure what camp your good idea is in might you ask? Do it and maintain it for a couple of years.
Incrementally Refined Tooling
I often find myself doing repetitive tasks over and over again on maintenance projects. With many years under my belt on some projects, there has been ample opportunity to build up a set of personal and open source tools to make my days a little nicer. The result is an obscene number of bash functions, aliases, text editor macros, ssh configs, etc.
I can’t write a post about legacy web app maintenance and not mention that the day I created a bash function to copy the remote production database of any project on to my local environment was one of the greatest days of my life (heroku, capistrano).
Let’s Wrap This Up
I fully understand that These Tricks to Make Legacy Code Maintenance Awesome! don’t apply to every situation. I’ve been truly blessed on multiple fronts that have allowed me to find enjoyment in this work by simply finding the positive aspects of it. Abusive decision makers, code inherited from a group of unreachable people who don’t know how to write code, working with technologies so old and so entrenched that there is just no hope. These are all things I haven’t had to deal with. But who knows, perhaps your calm could be so enhanced that these problems reveal themselves to just be another set of worthwhile challenges.
Originally published at www.viget.com.