Page 1 of 1

A Funny Story About Bad Source Code

Posted: Fri Jun 14, 2013 9:25 pm
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

Re: A Funny Story About Bad Source Code

Posted: Fri Jun 14, 2013 10:19 pm
by Gwynzer
You may enjoy CodeSOD on The Daily WTF. It's full of poo coding.

Re: A Funny Story About Bad Source Code

Posted: Sat Jun 15, 2013 4:45 am
by KoffeinFlummi
That's just sad...