Last week I pulled an all nighter at work. I hadn't done one since the death march project last year.
A problem was found in some code that was to be used for an imminent customer demo. It turned out to be a newly discovered bug in the same troublesome code from the project last year. Fortunately I was able to find and fix the problem, and the demo went more smoothly.
It was a long night. I was finished up some other stuff and putting on my jacket to leave at around 8 PM when my director comes running out of his office to tell me there was a problem and could I look at it. So I wasn't really prepared for it. Fortunately we have a coffee machine at the office with Starbucks coffee. I put on a brew. I ended up drinking most of it through the night - yuck!
I'm glad things turned out pretty well. People seemed appreciative of it. The next morning one of the product managers said he'd go to McDonald's and get me whatever I wanted for breakfast. I got a sausage McMuffin and coffee. McDonald's coffee is pretty good. That was a nice gesture by him. The grease hit the spot.
Hopefully this will be the last all nighter due to that troublesome code base. Am I confident we've found and fixed all of the bugs? Hardly! In the next product release most of that problematic code is now rewritten. Going forward I expect things will work much more smoothly. Also I can actually really understand what the code is doing now. So if there is an issue with either my code, or the external systems that interact with my code, it will be significantly faster to isolate problems and fix.
Generally I prefer to avoid rewriting existing code. It is generally difficult to justify the effort to spent developer time revisiting code that seems to work. In this case we wanted to improve product performance, so we had to revisit the inherited code. Plus we will save maintenance headaches going forward by avoiding situations like the one described above.
I don't have an equation for when to rewrite. It's a decision you make based on your experience, judgement and instincts. I'm generally skeptical of the value of rewriting code that seems to work and whether you'll truly be better off for doing it.
Sometimes there can be political pressure against rewrite. There may be a large sunk cost in the existing code base. Also a rewrite could be seen as a knock against the reputation of the original developers, so that may not be popular.
Still, when you know that rewrite is the best solution then you need to push ahead and do it.
No comments:
Post a Comment