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.

May 2017

Flubbed Buzz

by in CodeSOD on

Interviewing developers always poses a challenge. You can’t rate their skills at writing code without seeing them write code, and most of the code they’ve written probably belongs to someone else. Writing anything non-trivial takes time, which both the candidate and the interviewer may not be willing to spend. Even then, it’s not always representative. And let’s not even talk about whiteboard programming.

Douglas’s company makes a compromise- they’ll give a time-boxed programming challenge. A developer is given two hours, access to the Internet, and a moderately complex problem. A smart developer might make some mistakes on the trickier parts of the problems, which is great, because it doesn’t fail them- it shows how they think. One candidate, Steve, never quite got that far.

Classic WTF: Time for a tblHoliday

by in CodeSOD on
It's a holiday in the US today, which tracking the dates on which holidays fall is always a complicated, fraught proposition. Let's dig back into the archives for a classic article which can help us celebrate this holiday. This article originally ran waaaaaay back in 2006. --Remy

For most, the New Year is great occasion: not only is it kicked off with a big bash, but it's so easy to trick yourself in feeling like you have a "clean slate", setting all sorts of great goals and resolutions, and just all-around feeling good. But for some programmers, like Dave Sussman, it's not so joyous of an occasion; each change of the year is like a mini-Y2K. These programmers are the guys who get to maintain systems with comments like ...

Lucee Execution

by in CodeSOD on

I Love Lucy title

Recently, at my dayjob, I had a burning need to understand how scheduled tasks work. You see, we've recently switched from Adobe Coldfusion to Lucee, and I was shaky on how Adobe did things before, so I wanted a deeper understanding of how the code I was working on would be executed. For the uninitiated, Lucee is an open-source reimplementation of Cold Fusion. And that's not the WTF.

Hard Reboot

by in CodeSOD on

Every day in IT, each one of us walks the fine line between "brilliant" and "appalling." We come across things that make our jaws drop, and we're not sure whether we're amazed or horrified or both. Here's a PHP sample that Brett P. was lucky—or unlucky—enough to discover:

Documented Concerns

by in CodeSOD on

There’s a lot of debate about how much a developer should rely on comments. Clear code should, well, be clear, and thus not need comments. On the other hand, code that’s clear the minute you write it might not be as clear six months later when you forget what it was for. On the other, other hand, sometimes a crime has been committed and we need the comments for a confession.

Austin S confesses his crime.

Strongly Bad Emails

by in CodeSOD on

If you want to send emails from a Java program, you might be tempted to use the javax.mail package, which contains objects for doing exactly that. It’s a relatively straightforward API, and while it’s a bit verbose, that’s hardly unusual for Java. You just wrap it up in a convenience function based on how you need to call it, and reuse that, right?

Well, PHP, an obviously superior language, already did that work. There’s a built-in mail function, which sends emails. It uses your php.ini file to figure out what SMTP service to use, making the parameters to the function more “obvious”.

On Punctuation

by in CodeSOD on

Have you ever fallen asleep on your keyboard? Aside from the awkward face-prints it leaves behind, did you notice yourself programming in your sleep? I suspect that Chris’s co-worker does sleep-program. At least, that’s the only explanation for the 7,088 line code-sample I’m about to show you. Don’t scroll too fast- there’s actual code mixed into the middle of this. And yes, I’m including all of the code.

Which is less than you’d think, from the line count.

Robotic Implementation

by in CodeSOD on

Pearl’s employer couldn’t find an off-the-shelf product that handled their call-center needs, so they developed one in house. One department didn’t want to use that front-end, so they developed a different one in house, but it still used the same backend… mostly. Another group did the same thing, adding some fields and extending the database. And then another.

Then there was an organizational restructuring, and suddenly the call-center reps found themselves in the annoying position of needing to do double- or sometimes triple-entry, in order to get all the right columns and fields filled out based on the current business rules.