Almost every developer at some point has addressed a software requirement with bad code or has implemented a hack to temporarily solve a problem. Sometimes there just isn’t enough time to do something right. Most of the time we can get away with it because it works just fine. If you’re feeling nice that day you might even flag the code with a comment explaining the hack and how it really should be implemented should another developer have the time to do so in the future. But how should a developer react when their boss asks them to implement a specific hack?
Maybe it’s not that big of a deal but everytime it happens it really gets me thinking. If upper management has become so comfortable with hacks to even suggest one then shouldn’t we be worried? What’s stopping the whole project from becoming one big hack?
Is there a policy or practice to help manage this? Who takes the responsibility to note the hack and makes sure that it actually gets addressed properly later on rather than forgotten? Maybe they shouldn’t even happen at all and that’s why there isn’t a good way to manage this.
Basically, I tried to fight it and lost. And now I have to deal with the consequences. Meaning, I have to write more hacks to get around the problems we didn’t want to address the first time.
If you like this blog please take a second and subscribe to my rss feed
Tags: Code, developers, standards
Comments: 7 comments
All the fields that are marked with REQ must be filled
Jeremy R
June 25th, 2008 at 4:24 pm
Something like that is going to vary from company to company. In many larger companies you’re going to have a tech lead/manager, and it should be there responsibility to address the issue and push for getting things done right.
I was working on a bug here and found a work around to get it fixed. I couldn’t find out why it was happening, but I figured out how to fix it. When I did the code review, the tech lead asked me why the problem was occurring, I couldn’t answer him. He then used a good analogy: Debugging software is like being a doctor. If a patient says they have a problem you can treat the symptoms or you can find the problem and eliminate it. It’s obvious to see how treating the symptom is going to continue to create and leave more problems around. Much like your last paragraph explained.
noah
June 25th, 2008 at 4:26 pm
Documenting the extra cost that a hack produces down the road can give you some ammo when those kinds of discussions come up.
Having to hack something usually means something slipped through the requirements and design stages. The real solution to that is to fix the gaps in your process that allowed that to happen.
Of course, if you’re dealing with legacy code, you have to dig yourself out first.
Toast
June 25th, 2008 at 4:56 pm
hacks=cheap
managements likes cheap
At my job at least, my Boss knows programming, so the project I’m working on isn’t full of hacks. As he understands that value in doing a more robust solution rather then just a quick and cheap one.
Merovingian
June 26th, 2008 at 1:50 pm
@Jeremy: Unfortunately it’s no more the tech lead’s job to get it done right than it is yours. It’s their job and yours to get the feature implemented as fast as possible, while making sure regressions don’t occur in the code.
@Noah: Unfortunately documenting side-effects is shooting in the dark, unless you can definitively say that the coffee maker will shut down if this code goes in. Most “hacks” don’t produce such clear consequences. If someone were to sit down and say “this code will break feature x”, 99% of the time the person will — in the process of assessing side-effects — come up with workarounds. For the other 1% the person will actually come up with a version of the hack that will not result in the negative consequences.
There’s a reality that new software developers need to understand: 99% of the applications out there have hacks, workarounds, and piles of WTF-quality code. Like Toast says, hacks are cheap and management likes cheap. But on top of that, rewriting code can introduce subtle bugs that break old behavior, and that can often be worse than the pile o’ hacks.
That’s not at all speaking for my employer, I base that largely on experience in smaller shops.
Merovingian
June 26th, 2008 at 8:15 pm
I think I reverted back to my traditional old-man-who-forgot-to-put-in-his-dentures-this-morning routine. As Ryan likes to point out, I tend to sit on my rocking chair and shake my fist at “those yungins”. Sorry guys :)
noah
June 27th, 2008 at 10:01 am
I forgive you. You ARE far older than us, after all.
Jeremy R
June 27th, 2008 at 10:20 am
@Merovingian: I agree on the level of writing code. My comments were more on the level of coding practices and standards within your company and when they are ignored for hacks. At least where I work, I can put my say in, but the managers have the final say and managers give more credit to what the tech leads say than others.
Leave a reply