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.

Jun 2012

Stringy Sting Verification

by in CodeSOD on

"The company I work for sells text-message related web services," writes Martin S. "Basically, you buy a subscription and then get access to our SMS gateway that has all sorts of fancy features."

"Being that we sell technology to other companies, I sort-of expected the codebase to be... well, not like this. Take, for example, this function (one of many of its kind) that verifies that a string only contains numbers."


The Table Selector

by in CodeSOD on

"In my native language of German," writes Christian, "the word quellcode is a pretty direct translation of 'source code'."

"Unfortunately, bad code seems to cross language barriers - as does that famous three-letter explicit adjective. But occasionally I’ll find a piece of quellcode that deserves its own special, localized expletive: quäl-kot. When I stumbled across this interface in our quellcode, quäl-kot was the first thing that came to my mind."


Date Selector of the Damned

by in CodeSOD on

"It's no secret that web developers are generally considered the red headed stepchildren of programming, and with good reason," writes Joe. "With its proliferation of forgiving and loosely structured languages and the huge demand for web developers in our modern web-centric world, it's not surprising that the field is practically overrun by script monkeys with no real programming background. Armed with a shelf full of books on all the latest web technologies and a subscription to Experts' Exchange, they enthusiastically pound away at their keyboards day after day, happily and cluelessly producing oceans of spaghetti code so bad that even Olive Garden wouldn't serve it."

"Over the course of a decade in web development, I've seen so much terrible code that it takes something truly unholy to elicit more from me than a deep sigh and a weary eye-rubbing... but, every once in a great while, the devil still opens hell's source repository and looses upon my screen a horror so foul that even one as jaded as myself weeps in bitter despair. This is one such horror. I apologetically present to you: the date selector of the damned.


Disconnection String

by in CodeSOD on

"In ASP.NET programming," writes Chad Braun-Duin, "database connection strings are stored in configuration files, and the standard way of getting your connection string from these files looks like this:"

ConfigurationManager.ConnectionStrings(AppName).ConnectionString

The Logic Behind Modern Maintenance

by in CodeSOD on

When the big merger was announced, the IT staff of both corporations was a little bit nervous, and with good reason: The day after the announcement, many redundant positions were eliminated. Miraculously, the IT staff on both sides was left almost untouched. With the integration of two disparate code bases, there was a lot of work ahead.

The Odd Couple

During this process, Doyle discovered that his development group inherited a widely used enterprise-level suite of Visual Basic 6 client-based apps from "the other side." Doyle and his team were used to working in VB.NET, C# and ASP.NET; they felt a little taken aback at this news. But no matter, they thought -- it was only Visual Basic.


tblIsThere

by in CodeSOD on

"I've been maintaining a 'certain' application for several months now," Trent writes, "it exists in a wonderful state of being partially properly written code, but mostly legacy garbage. I've done my best to avoid anything in the database realm, but a change request forced me to journey down that dark path."

"When scrolling through the countless number of tables, I noticed something called tblIsThere. This is what it looked like:"