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.
« Feb 08

March 2008

Apr 08 »

Jed Code

2008-03-28
"About two years ago," Simon writes, "I worked for a small telecommunications company. Turnover was fairly high, leaving not much consistency in the way applications were developed."
Sometimes you see some code and can feel the frustration of the original developer. Sometimes it's because of profanity-laden comments in the code, other times it's because you can tell that they were right on the brink of a major breakthrough, but gave up.

N-Replace Zero-Test

2008-03-24
Thomas Nordlander writes: "The Swedish Church of Scientology's scary personality test contains some pretty awesome JavaScript validation. Consider the ingenious way that they make sure they are dealing with numbers."

Not So Simple

2008-03-21
"It should be pretty simp--" David M cut himself off. He learned his lesson. Nothing at his new job was Pretty Simple.
Submitted anonymously: "I found this in a data access layer for an application testing framework. The object has fields that are obviously meant to contain integers, doubles, and DateTime objects, but they are all strings and this is the only constructor:
James H. writes "If you had to programatically output a list of HTML <a> tags linking to anchors for the Alphabet like this:
The value of Pi is not as 3.14159265…ish as many of us would like to believe. Legislators in Indiana once declared Pi as 3.2, 4, and 3.23. Staunch biblical mathematicians insist that it's 3. The whole thing is a mess: everyone just has to have their very own Pi.

Finite State Arg

2008-03-11
"It's not every day that you come across a hand-coded, table based parser," writes Joel Davis. "That's pretty hardcore. I figured it must have been needed for checking if millions of strings were uints in some super-important inner-loop. Obviously, there had to be a reason to avoid 'strtol', 'atoi' or even 'isdigit'..."

Boolean Integers

2008-03-07
Pop quiz, hot shot. There are seven different true/false flags. You have only a single integer to represent them. What do you do? What do you do?

Pretty Simple

2008-03-05
"It should be pretty simple," David M naïvely stated, "just look in the Agent_ProductLines table, right?"
« Feb 08

March 2008

Apr 08 »