Crappy code aplenty

I was reading some code today; it made me cry. On the positive side, before I ran out of kleenex, I realized that the only function of the code was to cause the bug I was experiencing. I removed the 309 lines of code and aproximately 190 bytes of data per-connection that it required, and after putting it through some hoops, the only side effect is that it no-longer causes the bug. Great.


Well, at least some good came from all the tears.

What bug just got squshed?


Haha.. I suppose it was the groundwork for some future feature that is now long forgotten? I’ve done that to myself before, partly due to my lack of comments :-\ …stumble upon a bunch of code that seems to be causing problems and find that it does absolutely nothing of consequence.

Is it a 1 time overage of 190 bytes per connection, or was it something that was constantly being passed?

What the heck was it supposed to be doing? Was it just braindead from the design onwards, or was it something that was supposed to be implemented, didn’t work, and ended up being implemented elsewhere rendering this code redundant?

It was a chunk of code that had been added experimentaly at one time, and then #ifdef’d out with a long comment explaining how it wouldn’t work.

Then, immediately above it, was almost the exact same code, with just enough deviations to tell it had been written anew, i.e. the same idea struck the same guy.

It depended on 3 arrays, each of which was too small by one size, and each of which *only* ever could use the last element of the array (the one that was missing because it was too small) so all it *ever* did was write its data into the wrong memory space. Don’t get your hopes up, it never caused anyone to CTHL although it may, a long time ago, have caused auto-despawns.

As to what it did … well nothing; the actual functionality I was looking for was housed elsewhere and works. This code and all of its data was self-contained except where I (during 1.25 dev) had thought this code was responsible for the functionality I wanted and had accidentally tied this code into something else, causing the bug (a complete crap out of all the beta processes and client).

So I swapped my code over to the real thing and this little bug-generator was complete redundant, and now gone :)

Ahhhh….fossilized bugs. extinct but still apparent in the rock faces of old code….

Now where’s that history eraser button? :)

Beer is a good history eraser. Too bad it isn’t selective in what it erases. :)

Leave a Reply

Name and email address are required. Your email address will not be published.

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

You may use these HTML tags and attributes:

<a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <pre> <q cite=""> <s> <strike> <strong> 

%d bloggers like this: