Thursday 13 December 2007

Decisions, decisions

Warning: this post contains content of a dull IT nature. If easily bored look away now. Although it does contain an endearing wee anecdote about Grandad Ambassador.

I'm a software developer by trade and today I find myself with the unenviable task of making a number of complicated changes to a piece of already very complicated code (which was originally implemented by A.N. Other).

With the new functionality being sufficiently similar to what already exists it would be foolish to add completely new code to handle the requirements, however, it is also sufficiently different to ensure that new and old will not play together nicely - or not as things currently stand anyway.

This leaves me with two options.

1. I can be a diligent developer, print out the existing code, then tear the whole lot down and implement both pieces of functionality from scratch in a clear, logical , concise way that will allow them to cohabit peacefully. This approach also ensures that the next poor sod to find themselves looking at this code will be greeted with code that is easy to understand and follow. There is a real danger however, that in rebuilding the original code, I will find myself shouldered with the responsibility of supporting code I had nothing to do with first time around.

2. I can hack the bejaysus out of of the existing code to make the new features fit. This will ensure that I don't change the original code and as such, will not be stuck supporting it. However, it would be akin to sticking the aforementioned new features on with blu-tack, sticky tape and chewing gum. Needless to say, it is generally considered bad practice.

Right now a little voice in my head is chanting "Hack it! Hack it! Hack it!". Unfortunately the bigger voice - the one which takes pride in its work and believes that, as Grandad Ambassador used to say, "if something is worth doing, its worth doing right" - has told the little voice to shut the hell up unless it wants its ass kicked.

Mind you, Grandad Ambassador was the type of man who would say "Its all fun and games until somebody loses an eye... unless its some type of eye gouging competition, in which case you continue until you find a winner" - so maybe his advice isn't all its cracked up to be.

What fantastic grandparents I have.


Stonedog said...

Hack it !!

sheepworrier said...

hack, hack, hackety, hack.

Caro said...

Hack it until such times as they give you the resources to re-write it from scratch.

There is NOTHING worse than other people's code though. You have my sympathies.

The Bad Ambassador said...

Oh I have the time to write it from scratch and I know its the proper course of action - its just the underlying minefield I'm wary of.

I would have to disagree with you about working with other people's code though - working with your own code and not having a clue what you were playing at is far worse.

I'm pretty disciplined when it comes to commenting and indenting code so generally it is easy to come back to. That said, I have on occasion revisited my own code and not been able to make head nor tail of it (even with all the comments) because I can't remember any of the relevant business rules.

Stonedog said...

I'd love to join in with this but I have no idea what you're talking about !!!

Medbh said...

The technical stuff is waaaay over my head but I think your grandfather is a wise man.