Hacking bad code to make it work

by Evil Buck on December 23, 2009

Should we ever put up with hacking bad code to make it work for right now? Is there such a thing as a temporary solution? Every so often I fight this mentality at work to just patch the code and make it work for right now. The “we need this yesterday” solution without ever thinking about the future consequences of our actions.
As much as I fight against, sometimes I have to do it. I hate, hate, hate hacking something up. I preach the fact that there is nothing more permanent than a temporary solution. I know it’s going to come back to bite me in the ass. The very second a change is wanted it will.
Why do I hate patching the code? I hate it because the blame will later get placed on me for bugs in the software due to design decisions out of my control. I guess I wouldn’t mind making the quick patch as much if later, when bugs are introduced because the code is so very unmaintainable and bugs are introduced with ease, they would take the blame for the issues. But no, it’s now my job to stay late and work harder for shitty decisions made by someone else who was unwilling to take advice, or forced the issue of not worrying about maintenance. God knows I hate more work, tedious work at that, for something that could have been avoided. Should have been avoided, was foreseen and cautions ignored.
You know the kind of code I’m talking about. The kind where you need intimate knowledge of every working part because all the code is so tightly coupled that making one modification means accounting for it in 15 different places or it will break. The kind where we decide that writing out javascript inside a string, passing it into a function, later to eval it is a good thing. See example -> http://club.cmstheme.com/demo100/Interface/templates/Interface/effects.php
So back to the original question. Should we hack it up? I say no. It will come back to bite you in the ass. Almost no one that is asking you to do it understands the implications. They don’t understand that writing bad code is a future of longer development times and is a ticking time bomb. But they will likely blame you when it does break. Of course there will be times when this is unavoidable, but make the best of it and rewrite small sections at a time. Or make the change, but make sure the next time you touch the code that it is understood that re-factoring time is mandatory.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Leave a Comment

Previous post:

Next post: