Mark McAulay

Digital Guy 
« Back to blog

Ignore the mess or re-write sloppy code?

Like all developers and web designers out there, I often get handed some legacy code to work on. I'm perhaps being too nice with the term 'legacy', let me try again. Sometimes I get handed the most sickeningly bad, amatuer, non-sensicle, written by demons in the shittiest part of hell code (yes...that's more accurate). The dilema is often what to do about it.

The purist in me wants to "scorched earth" it and write it properly. Now that my name has been associated with it, I'm not going to get tarred with the same brush as the person who decided it was production ready in the first place.

The employe in me tells me that i've only got a fixed number of hours to get this job done and re-writing it is just not going to happen in the time allowed for the job. I can either patch it up and deny any knowledge of ever seeing it or i can re-write it, or at least re-write the worst of it in my own time so that future developers looking at it wont want to kick my head in.

How do others deal with this scenario?

Comments (3)

Oct 24, 2010
studentdesigner said...
I have this problem looking back at my own code.

I find the best way to deal with it is to write my self abusive comments to fix at some point in the future.

Perhaps you could tag it

// The following was written by demons in the shittiest part of hell
// The author in my opinion is an idiot

And then with yours

// You see this! This is mine. This is why I deserve to be paid more. God I'm good.

And occasionally pepper the code with simple

// ffs

Works for me

Oct 24, 2010
RyanRoberts said...
Well it depends whether it's worth it. Sometimes I'll rewrite (which may mean in my own time) other times I'll make it clear this was not my creation and adapt it or I'll just get the job done, move on and not care.

Recently I've been updating and maintaining code written by Indian developers, believe me when I say there's NOTHING worse than that.

I've always gone by this advice:

— "Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live."

Oct 24, 2010
Mark McAulay said...
@studentdesigners a novel approach but probably lacking in professionalism. I do like it though haha

@ryanroberts yes, i've heard that quote before and can definitely live with it. I've worked on 'outsourced to Indians on the cheap' code before and agree completely. The expression 'false economy' springs to mind.

I think in this instance, i'm just going to apply some fixes in the style of the original author and deny ever seeing it thereby absolving myself of all blame ;)

Leave a comment...