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.

Apr 2013

Coin Toss of Doom

by in CodeSOD on

The ticket at the top of Brian's queue seemed strange, but not entirely unheard of. A user had entered in a bit of data in a text box on the company's flagship internal web app, clicked Submit and - boom - immediately redirected to a 404 error page. The next ticket was for the same app, same page, same text box and data, but, to make things interesting, the user reached instead a Java exception page.

The rest of the tickets landing rapid-fire into Brian's inbox were more of the same...and using the user's input, Brian could reproduce both results at will. So. Much. Fun.


The Apex of T-SQL

by in CodeSOD on

Thomas has some problems around the office. Specifically, the code he supports has all sorts of different ways to generate HTML. Rarely, it’s WebForms code living in as ASPX. Far more often, it’s hard-coded into the CodeBehind. Sometimes, it’s sitting in a resource file.

And then sometimes, it sits in a stored procedure like this:


Do Not Remove Complete!

by in CodeSOD on

It wasn't easy for Ben to find a snippet from the monstrous codebase he maintains that fully demonstrates the Whiskey-Tango-Foxtrot rating it deserves. Sure, there were calls to the data layer from the UI, and, yeah, there was at least one method called DoSomething() that no one dared to modify. But those are all de rigueur at The Daily WTF. He needed something... more. Something worse. Something layered, like an onion, and twice as eye-watering.

He needed this:


Nine Ways to Tuesday

by in CodeSOD on

Devan L. was playing with his young daughter, when she asked him if he knew all of the days of the week. He replied: Sunday, Monday, Frogday, Flubberday, ...

She quickly admonished him for being silly. He told her that he was a very busy man and that there were too many days to remember. They laughed.


Switching It Up at the End of the World

by in CodeSOD on

Conditional operations are so common, languages have evolved an entire family of ways of expressing them. This lets the developer choose the best expression for their needs, whether it be a traditional if/then/else, a switch block, or a ternary operator.

Sometimes, developers don’t make the right choice. Sometimes they don’t make the right choice twice in the same statement. Sergej sends us this:


Computers Need Weekends Too

by in CodeSOD on

We are all familiar with the cycle. We arrive at work on Monday ready to face the week in front of us. Over the course of the next five days the drudgery of the grind and the pettiness of the problems that attack us on all fronts wear us down until by Friday we can barely put one finger in front of the other. We celebrate our freedom on the weekend with all manner of revelry. Then, rejuvenated, we enter Monday with a spring in our step only to find ourselves beaten down again.

Yes, we all know and live this pattern. But we don’t expect our computers to emulate it.


Tough to Separate

by in CodeSOD on

Reynard submitted the following through the Visual Studios plug-in. He writes that he was charged with making the Customer Values page go faster. Depending on the client, there could be hundreds or thousands of Values that can be attached to a user (Client). The user manages them through a standard checkbox-laden page.

He quickly came to learn that you'd only be able to pry CSV from the lead developer's cold, dead code.