[prev] [thread] [next] [lurker] [Date index for 2003/08/28]
I'm actually talking about a particular bit of code that I've inherited but I've seen this phenonomem elsewhere so I'll paraphrase. I'm not sure if there's a neat buzzword for this particular species - neither lasagne nor spaghetti code seems to work. Perhaps 'spirelli' code. Anyway, lurching back to the point. I've inherited this code. The task seems simple enough - indeed I have a suspicion that if I was to reimplement it from scratch it would take a week or two. Instead, on and off, I've been poking at it for nigh on six months now. Now to be honest this is a week here and a week there but still. Six months. You could rewrite Emacs in Perl in that space of time. Or Mailman :) Why is this code so bad? Well, its lineage for a start - I can practically see its evolutionary tree. Currently it is a rag tag collection of shell and Perl scripts. Some of the Perl scripts obviously used to be shell scripts to the extent that they actually SHELL OUT TO OTHER PERL SCRIPTS. Not for forking reasons, oh no. Just because, well, the original author had partaken of the crack pipe and not drunk deeply from the cup of refactoring. I have to concede that they did move some of their 'require'-d code into modules but the design of those, plus the fact that they lurk in various lower case namespaces or, and I'm not sure if this is better or worse, in the Test:: namespace, means that this is not enough to let them off the hook. Even as I write this I'm struggling to explain why this has caused me so many problems. On paper, and I know this because I had to write it down yesterday, it all seems perfectly easy. But, obviously there is, otherwise I wouldn't be writing this. My two, no wait, three major issues with this stuff are these : 1. The code is *incredibly* brittle This to the point that if I leave it for a week and then run it again I can practically guarantee that it will not work, often failing silently, and I will spend a full day poking around trying to diagnose the problem. Often there will seem to be no reason for this. 2. It's amazingly hard to follow. There are several reasons for this - my particular favourite being the lack of indenting, the terse variable names, the overuse of hash references (which are normally fine but become incredibly difficult to follow when nested 8 deep and passed between required files to functions with 10 arguments with no consitent naming scheme or ordering), the fact that there are many "actions at a distance" not least the use of Environment Variables as some sort of perverse global variable system, like the author went "well, I'm told globals are bad so if I put then in ENV then nobody will know". Truly, the list goes on and on. I haven't even mentioned the lack of comments and the long, undocumented regexes with unprintable characters in. On and the fact that various libraries are in various people's home directories. Testing is also a problem because a trial run takes 4 hours and requires a full days worth of data meaning that a fix checked in on Monday won't be checkable until after lunch Wednesday. 3. I'm not allowed to refactor. Apparently the main reason I'm not allowed to is that then it won't be 'trust worthy'. I've mentioned Unit tests but these have been roundly ignored. Also, the code has been internationalised from the original which is also being developed (don't ask why there are mutliple branches). So I can't refactor unless I want my life to be a manual patch applying hell. Hell, I can't even use Perl Tidy (I tried - waaaaaay too many spurious deltas) Actually, there's a fourth. 4. It makes me feel shit I know I'm not a bad programmer[0] (stop sniggering Richard). I've written far more compilcated programs than this. Yet it has single handedly been the most disasterous project I've ever worked on. I seem to find it impossible to give, let alone keep, a deadline. It saps my confidence and I have huge problems forcing myself to work on it which in turn makes me feel worse. Et cetera, ad nauseaum, ad infinitum. Right, that's enough moping.
Generated at 14:02 on 01 Jul 2004 by mariachi 0.52