I had a fortune (or misfortune) this week to tackle some old code. A feature written about 4-5 years ago by a developer who is no longer with the company needed to be revived and brought up to date.
The developer who originally wrote the code came to Java from VB, PowerBuilder or something of that sort. He worked in the environment where there was one GUI event loop for the entire application and you had to lay things out on the screen pixel-by-pixel. Needless to say his Java code looks very similar -- 1000 line long if/else/if/else/if/else clauses, Swing panels laid out pixel-by-pixel, etc.
I had to add a few buttons to one of the panels he has written and I found it literally nauseating to look at that code. In order for me to add a button I would have had to figure out his pixel-by-pixel layout, move things around, recalculate the coordinates, and find the right place in the 1000-line long if/else clause.
That had to change. I wasn't about to lower myself to the level of such incompetence. In Java you don't need to lay things out pixel-by-pixel, and you can have action listeners for each component and let Swing handle the event loop. We haven't been in the C GUI world for at least a decade now. So, I rolled up my sleeves and redid the whole nine yards using Box layout and proper ActionListeners.
The moral of this story is that just because the code is already written and is in production doesn't mean it can't or shouldn't be rewritten. Poorly written code is impossible to maintain and only contributes to errors and increases costs.