Maintainability Is Relative
Contents
I just found a great example of the variability of the need of creating maintainable code.
Somewhere around 2006, I created a script that posts to the Livejournal community daily_tao a new chapter of the Tao Te Ching every day. Today in 2016, I had a need to look for the script, the second time in maybe the last eight years that I had to look at it.
I temporarily wasn't sure of where that script was. I remembered it was running off of a cronjob, so… Some machine with a *nix-like OS. Then I remembered and found it. I'm going to offer two versions of the code to you: the one that is in the cronjob, and .. A rewrite that I never deleted (and now of course, I have no idea why I never did).
The original:
|
|
I saw this, and it didn't make a ton of sense. Thankfully it's a very short script so I was able to piece it together quickly. Today I probably wouldn't write it this way, but… It works, so why would I touch it?
The new script is in Ruby. I say new because I learned Ruby after Bash, and once I knew Ruby, it was my preferred language. I'm guessing I wanted to rewrite the script so it would be more legible, and then… For some reason, I never replaced it.
|
|
My favorite thing here is probably the second-to-last line of the Ruby script.
There are no tests for any of this, because I definitely wrote this before I knew you could test your code.
And the question remains: should I write tests? Should I refactor? Should I fix it, rewrite it, etc?
And the answer remains: No. It works. There are no new features to add. Just leave it be.
Author Aldric Giacomoni
LastMod 2016-10-23