Code maintainability is important.
There, I said it. I’m not trying not to be hyperbolic, but it has become increasingly apparent that code maintainability was extremely undervalued by many of the people who wrote the original code for my clients. The original developer didn’t focus on long term maintainability, so now the client is stuck with a code base that they don’t understand and doesn’t work and I have to fix it.
I mean, look at this garbage I found on the internet somewhere from a non-related project that isn’t covered by my NDA agreement:
Just looking at that function gives me nightmares.
Imagine trying to track down a bug and you come across that. First question, what is that code even supposed to do? second question, what is it actually doing? There have been times where I do some debugging on a client’s code base and it literally takes hours for me to answer those two questions. Its not so bad, considering I sometimes charge by the hour, but at the same time it would be much better for both me and the client if that code looked something like this:
Much better.
That is code that I wrote about 18 months ago for an Android game, by the way. Look how easy it is to figure out what the code is supposed to do: its in the comment at the top! and look how easy it is to figure out what it is actually doing! Every line has a comment!
To be fair, that is probably too much commenting for such a simple function. Better to err on the side of too much maintainability than too little, I say.
How about this function from a database rewrite I did earlier this year?
Its beautiful! Not only does the top comment explain what the code is supposed to do, it even lays out the assumptions that were made when it was written. It only took an extra couple of minutes to type out that comment, but it can save hours when and if I ever have to come back to it to fix or update it in the future. It has great maintainability.
Obviously some code is more complicated than others, and the non-complicated code doesn’t really need all of the extra comments to make it maintainable. But professional code does. Maintainable code does. Code that is actually useful does.
Heres another example of code with great maintainability from another project I worked on. Look upon the glory that is maintainable code:
Jealous? you should be. Considering the crap code that I am trying to fix for my client right now, I’m actually jealous of myself. It would be great if the original person who developed this code would have put a focus on maintainability.
sigh. Well, atleast I’m getting paid to fix it.
Joe Ryan
Joe is the founder of Creative Ape Studios, a Minneapolis based software development firm that LOVES maintainable code. From Apps to Investment Algorithms to Websites, Creative Ape will get it done for you so you can focus on execution. Reach out today and lets talk!