?

Log in

prawnwarp
i've never tried to create a wow
Code stink 
18th-Jun-2007 04:23 pm
This morning I had to dive into some code I didn't write to try to figure out why it was [boring technical details of the actual error omitted but it was broken, ok?].

You might have heard the term "code smell" - this code doesn't smell, it stinks. It stinks of many things, chiefly convoluted OO design with about thirteen too many layers of abstraction, and hideous brittleness, and dog poo.

I don't know how programmers can merrily write this stuff and not noticed the stench. Imagine a furniture designer building a chair. The chair has big spikes coming out of the seat. If you sit on it from the right side, it is very uncomfortable. If you sit on it from the left, not only do you get spiked, but the whole chair collapses under you, and a flag comes out of the chair on a spring. The message on the flag says "that was your fault, try again."

The designer would probably notice that there was something wrong with the chair well before any actual users got to try it out, but for some reason (actually I have a pretty good idea of what the reasons are but don't stop me, I'm being rhetorical) programmers will happily release code that is the exact equivalent of the unspeakable chair.
Comments 
18th-Jun-2007 06:56 am (UTC)
A better analogy than the "chair with spikes coming out of the seat" would be the "chair that uses several strata of dried and wet shit for cushioning and intermittently collapses, in some cases causing other furniture to collapse for no apparent reason, even in entirely different rooms (and in extreme cases, buildings)."
18th-Jun-2007 11:59 am (UTC)
Haha, yeah, there's badness of that order in the system I was working on as well, but that wasn't the immediate problem. (I wonder if the term 'Big Ball of Mud' wasn't originally a euphemism for 'Huge Pile of Shit'.)

The immediate problem - when I actually found it; there were two almost identical sets of nested methods doing very nearly the same thing, in two different and almost orthogonal classes - had logic which was so poorly thought out that it really did seem as perverse as a chair with spikes coming out of it. The kind of code that you can't believe someone wrote in innocence - surely it must have been deliberate. (I've had that experience with my own code, which is worse.)

And of course the reason this stuff persists is that refactoring it would be horrifyingly slow and brain-destroying; on the other hand, "let's rewrite it again from scratch" is never a popular option. I'm trying to come up with a strategy to rewrite it one chunk at a time.

This page was loaded Jul 28th 2017, 10:57 am GMT.