A Funny Story About Bad Source Code

Off-topic discussion, where anyone can talk about almost anything.

Moderator: Executive

Post Reply
Gamma009
Posts: 89
Joined: Mon Feb 13, 2012 3:16 pm

A Funny Story About Bad Source Code

Post by Gamma009 »

I've been working on converting the code for a COM+ based service to a non-COM+ based DLL today, and well, I have discovered that the source for this thing is atrocious. It is 5% actual functionality and 95% hacks, which an unfortunate intern (like me) has to sort through.

Here is what I found: (I've color coded the functions/classes and bolded the data structures)

1. Base Services calls BaseExecutable.getFilteredMessages, which returns a Vector from the standard C++ library.
2. Base Services then iterates over the vector and does some stuff.

3. Of course, BaseExecutable.getFilteredMessages calls BaseMessageList.getFilteredMessages, which returns a custom-coded Linked List that does the EXACT same thing as the Linked List in the standard C++ library.
4. BaseExecutable.getFilteredMessages then iterates over that list's contents, adding everything from the Linked List to the Vector in the exact same order and returning the vector.

5. In BaseMessageList.getFilteredMessages, it calls MessageDataSet.getFilteredMessages, which returns a C++ standard Red-Black Tree.
6. BaseMessageList.getFilteredMessages then iterates over the Red-Black Tree's contents and adds them to the custom Linked List, once again, same order.

7. Finally, MessageDataSet.getFilteredMessages takes its private instance field, which is a standard C++ library Vector, and adds all its contents to the Red-Black Tree in the same order...just to, you know, make sure that the vector itself wouldn't get changed...
...
...
...
...
...
...
...
Image
Image
Gwynzer
Executive
Executive
Posts: 3098
Joined: Wed Feb 15, 2012 5:13 pm
Location: England :(

Re: A Funny Story About Bad Source Code

Post by Gwynzer »

You may enjoy CodeSOD on The Daily WTF. It's full of poo coding.
Image
KoffeinFlummi
Supporting Member
Supporting Member
Posts: 1686
Joined: Mon Feb 13, 2012 1:08 pm
Location: Germany

Re: A Funny Story About Bad Source Code

Post by KoffeinFlummi »

That's just sad...
Image
Post Reply