Devin Moore

Feb 2007

When A Problem Comes Along, You Must skipit

by in CodeSOD on

An anonymous snippet comes from the land of Visual Basic, where people continue to prove on a daily basis that simplicity of syntax offers no protection against screw-ups:

Having recently started a new programming job, I've quickly discovered what most of the day-to-day grind entails: Deciphering and cleaning poorly written Visual Basic code before actually being able to perform my assigned work. Our codebase has plenty of the usual suspects: Variables with meaningless names like "AA" and "bbb", thousand-line functions (which approach VB's built-in limits), no-ops, unreachable code, gobs of copy-and-pasted code, and a few instances of this little construct (irrelevant code removed):

If {condition} Then

        ' ...code here

        Goto skipIt

End If

' ...more code here


A Real Brazil Nut

by in CodeSOD on

Code snippets know no geographic boundaries.

Jose Sobrinho sends us a great abuses of IF statements all the way from Brazil. The best of his "pearls" is a real mind-bender:

Rarely Just TRUE or FALSE

by in CodeSOD on

Our friend R.L. writes in with a twist on a common snippet, illustrating an important scientific fact: solutions in life are rarely just TRUE or FALSE ...


The Really, Really Long Way

by in CodeSOD on

Jeremiah V. writes to share with us another snippet fact: there is always a longer way to do something, no matter what language is used. In SQL-92 compatible databases, it is a challenge to have a dynamically-generated ORDER BY clause, but there are a number of ways to produce a reasonable implementation. For instance, a quick Google search turns up using a combination of CASE and CONVERT to handle a dynamic ORDER BY statement with different column types.

Jeremiah found the much, much longer version of a solution to this problem. Once he stopped laughing, he notes for us that many, many permutations are missing, save for some of the ORDER BY criteria being treated as a single unit. The CASE and CONVERT functions are avoided in this implementation, but the code size becomes enormous... let's hope they don't add a new column any time soon:

So Bad It Needs An Apology

by in CodeSOD on

My new hero John Connor submitted an epic code snippet.  Let us dissect this in two parts, because it is such a massive SOD that trying to tackle it all at once could cause brain trauma.