Frankenstein programming


I'm spelunking around in some code for a client looking for a nasty bug that's hard to reproduce. The code is less than ideal... It's the kind of code that's been put together by what I refer to as 'Frankenstein programming'; lots of unrelated bits and pieces have been collected from various places and stuck together to make something that looks about right. Unfortunately we're at the point where we need a vast amount of power to give this thing life, and I for one don't see a thunder storm on the horizon...

Eye of newt, and toe of frog, wool of bat, and tongue of dog. Sometimes you know that your project requires you to do X, but you don't quite know how to do X. You google and come across some code somewhere, if you're lucky it's got some documentation. It looks like it does X but it uses a technology or programming style that you're not currently using in the project. Doing X doesn't require the technology or style; it's just that the person who did X and put it on the web chose to do it that way... There are two potential courses of action at this point; you can use the partially documented X from the web to learn about how to do X and then translate that knowledge into something that fits with the technologies and styles that you're actually using; or you can hack the web version into your system and patch up the inevitable gaps as best you can... Time pressure and laziness often causes the second course of action to be the one that's taken. The problem then in that there's no consistency in the resulting code; styles and technologies change from one area of the code to another for no good reason. The code is more complex, harder to understand and during maintenance you can waste a lot of time trying to find meaning in the madness.

The abundance of bits and pieces of freely available code on the web can tempt you into just sticking them together and hoping for the best. It's natural to want to reuse code so that you can make progress faster. The problem is that most code isn't really designed for reuse and even if it is it's unlikely that the assumptions that the original designer made have been fully documented. There's a world of difference between throwing a piece of code up on the web and marketing a code library.

With code from the web, you really need to try and get an understanding of it before you use it; prototype and test with it outside of the main code base and then take some time to integrate it properly with your existing code.

Each piece of code that you use but don't quite understand adds potential bugs, and bugs tend to come and bite you at the most unfortunate times...


Why you avoid using hungarian notation ? Is it a habit or some real reason behind it ?

Why you avoid using hungarian notation ? Is it a habit or some real reason behind it ?

Why you avoid using hungarian notation ? Is it a habit or some real reason behind it ?

So good you asked it thrice?

I personally dont think it adds any value over well chosen variable names. If you have well chosen variable names then the hungarian warts just get in the way IMHO.

Bats have wool? ;)

I agree 100% re: Hungarian notation. It makes everything harder to read, and it makes for more work if you change the type of a variable.

Shakespeare seemed to think so:

I wonder if you can harvest it to make expensive scarves or whatever... ;)

Leave a comment