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.

Jul 2016

OhgodnoSQL

by in CodeSOD on

How about those NoSQL databases, huh? There’s nothing more trendy than a NoSQL database, and while they lack many of the features that make a traditional RDBMS desirable (like, um… guaranteeing writes?) , they compensate by being more scalable and easier to integrate into an application.

Chuck D’s company made a big deal out of migrating their data to a more “modern”, “JSON-based” solution. Chuck wasn’t involved in that project, but after the result went live, he got roped in to diagnose a problem: the migration of data from the old to the new database created duplicate records. Many duplicates. So he took a look at the migration script, and found piles of code that looked like this:


Lunatic Schema-tic

by in CodeSOD on

One day, James’s boss asked him to take a look at a ticket regarding the “Cash Card Lookup” package, which had an issue. James had no idea what that was, so he asked.

“I don’t know,” his boss replied. “I just know the call center uses it. You’ll need to talk to them.”


Hanging By a String

by in CodeSOD on

We all know that truth is a flexible thing, that strict binaries of true and false are not enough.

Dana’s co-worker knew this, and so that co-worker didn’t use any pidling boolean values, no enums. They could do one better.


Classic WTF: RegExp from Down Under

by in CodeSOD on
This particularly bad example of regular expressions and client side validation was originally published in 2009. I thought Australia was supposed to be upside down, not bass ackwards. - Remy

"The company I work for sells vacation packages for Australia," writes Nathan, "and for whatever reason, they're marketed under different two different brands — redacted-travel.com.au and redacted-travel.com — depending on whether you live Down Under or somewhere else in the world."

Nathan continues, "one of the requirements for the international website (redacted-travel.com) is to disallow people from within Australia and New Zealand to make bookings. But the way this is done from the front end... well, it's a real gem."