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 2012

The Long Glow

by in CodeSOD on

"It was around 2005 when I landed my first job at a small software company," writes Derek, "I was the youngest programmer on the team by at least a decade, and my coworkers certainly made sure I remembered it. Fortunately, it was all in good fun, but they reminded me that I had a long way to go and that I should learn from older, more experienced folks – presumably like them."

"In the midst of 'learning' from them, I noticed that on many of the companies projects used the same pattern where the main window five different buttons and three stock photos. Each button had a glow that appeared on hover and the first three buttons would trigger a corresponding stock photo to display. Nothing too crazy, though this hi-tech feature took my predecessor astonishing 280 lines of code… in each project it was implemented in."


The Extensible Menu

by in CodeSOD on

"The product we maintain has come a long way," writes Tod Hoven, "the backbone is a three-tier VB6 application that is slowly being ported and rewritten in .NET languages (VB.NET / C#)."

"But some code, however, just isn't quite cut out for conversion. Take, for example, the navigation/authorization mechanism used by many of the core screens:"


Representative Table

by in CodeSOD on

"This is a small peek into the production database of one of our client's systems," writes Walter. "I wish I could say that this was an unused table, an isolated occurrence... or even that I had some other job prospects. But sadly, none of those are the case."


Epoch Billing System

by in CodeSOD on

Everybody in the IT department was quite happy -- even a little surprised -- with how well the outsourced project to replace the legacy billing system was progressing.

Well, actually, the project managers weren't all that surprised. Over the past four months, they'd pumped out reams of specs and design documents, often boasting that their level of planning hadn't been seen since the Apollo missions. So, for them, the fact that everything was turning out as designed spoke volumes about the success of their planning and processes.

New Billing Code


The Bit Setter

by in CodeSOD on

"Bit manipulation can be tricky," writes Nathan, "especially if you have no familiarity with bitwise operators or logic."

"At least, that's what my smarter-than-built-in-language-features colleague must have thought when he authored setBit. Fortunately, his code was the only one that utilized this function, as it doesn't quite work as advertised."


Mybad

by in CodeSOD on

"At my company," writes Ryan L, "we have a 'certain' developer who has been here a while but is very reluctant to learn or improve. In fact, he actively works against the rest of us when we want to implement pesky things like proper version control, design patterns, or architecture to our code behind having 3000-line code-behind files."

Ryan continues, "I was exploring our SVN logs and came across something checked in by this "engineer". It was a single file, with a commit message of 'Mybad'. The file turned out to be a config file. Here was the previous version checked in: