Jan 15 2008 at 2:40pm
When you can’t just start over
Do you ever have the task of fixing someone else’s code? Someone else’s crappy code? Don’t you wish you could just start over?
You just need to make a few small changes. But the CSS is such a mess! It would be so much better if you could just re-write it. Cut down on the crud and make it all nice and clean and elegeant. Take it all down like Mike Holmes.
But there’s not enough time for that. The changes are due by tomorrow so you have to just make do with what’s there and add in your own necessarily crappy code.
Sigh… this happens to me all the time these days. And I’m sitting here thinking, should I just fix it? How long would it take? There’s a little brick wall here — do I just climb over or do I start again?
Granted, this code isn’t *that* bad. It’s relatively standards-ey (circa 2004-ish). Just lots of layers of disorganized CSS a bunch of IE5 hacks. It still bugs me though.



Adam H January 16th, 2008 at 9:26 am
Do what I do. Start working on the replacement version in free moments so eventually you can roll it out from scratch. It is like a branch in the versioning, patches can still be applied to the old branch but the new branch is where all the development is going on.
Good luck with that!
Ruben January 18th, 2008 at 11:24 am
I don’t do much CSS or client side but I know the general feeling about having to fix code that stinks. I have been seriously thinking about to just decline to do that kind of work. The general problem here of course is that people that pay for software never read code. To even think that they should have some appreciation of beautiful code…. well, it is not about to happen any day soon. As long as the code does the work it is good code…. The only way to their ears is to talk about maintenance cost. “This code sucks and I would have been able to do the change twice as fast if the code had been nice and tidy.” The reply most often is a resigned: “ok – but your fix is still cheaper than the rewrite.”.
Another related thing that distrubs me is when I write a nice piece of code and sign it with my name. Then some other person ruins my nice code with nasty fixes and doesn’t sign his work so it still appears as if I actually coded the thing. (Ok – the versioning system keeps track of this but still….)