Recent CodeSOD

Code Snippet Of the Day (CodeSOD) features interesting and usually incorrect code snippets taken from actual production code in a commercial and/or open source software projects.

Sep 2012

Have you Tried Arrays?

by in CodeSOD on

Diego inherited a system from a "senior" developer. The largest challenge in the system was that it had to handle DataSets that could contain up to 700 columns, but could contain less.

Judging by the code, it's easy to see why a task of this complexity could have only been implemented by a senior developer.


A Byte of Booleans

by in CodeSOD on

Carl’s investigation started when he found out that his predecessor had set up a cronjob to restart Tomcat every three hours. Carl never tracked down one specific reason why the application server needed to be restarted every three hours, but paging through code like this, he knows the problem’s in there somewhere.


            

Bank of Scotland's Keyboard Trap

by in CodeSOD on

When you're designated as your family's official internet support technician, you find that what someone perceives as the biggest web-based WTF often turns out to be something that's relatively easy to dismiss being attributable to poorly designed or misleading UI.

However, once in a while, something truly special crosses your path, much like when Wladimir Palant's father asked him to look into some weirdness on his online banking login page. As it turned out, the Bank of Scotland invented some very creative keyboard input validation:


The Lone Rangers

by in CodeSOD on

It started when David tried to access a Singleton and got a null-pointer exception. Then he noticed some bugs where the Singleton had inconsistent state. And then he looked at the code…


            

How to Extract Text from HTML (Experts Only)

by in CodeSOD on

If you ever hit upon a scenario where you need to mine meaningful text data out of any set of HTML files, you will likely find yourself facing a potentially hairy situation.

With the ads, silly social media add-ons, sidebars, toolbars, and likely WTF-level web page coding practices, unless you’re looking at a set of pure vanilla, consistently designed pages, it can be a big mess.


Big-Data JSON

by in CodeSOD on

When Matthew saw this attempt at a JSON serializer, he had one question: why didn’t you use one of the many libraries we already use in this application?

The answer was, “Because on ‘big data’ procession you should to avoid creation of many objects in the Java!”


Pick-a-State

by in CodeSOD on

If you're a regular reader, you'll recall Rachel's code submission from last week where we saw super fun things like first and last names represented by double variables. Well, if you enjoyed that, you'll probably love today's CodeSOD.

Rachel wrote, "This method was part of the State class. Apparently if you want to know what index NY is, you need to create a copy of the State class and call it's .get_state_index() method."


Hexed Id

by in CodeSOD on

The web application David inherited has one main job: fetch articles based on the integer ID passed on the URL. The only trick to the whole thing is that the ID might be encrypted and represented as a hexadecimal number.

David didn’t really look into the process until someone complained that the system was serving up the wrong articles. When he read through the code, he saw this: