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.

Oct 2022

Throw it $$OUT

by in CodeSOD on

If there's one thing worse in code than magic numbers, it's magic strings. Sean inherited an antique Visual C++ application, and the previous developers were very careful to make sure every string was a named constant.

const char $$B[] = "$$B"; const char $$E[] = "$$E"; const char $$L[] = "$$L"; const char $$IN[] = "$$IN"; const char $$OUT[] = "$$OUT"; const char $CODE[] = "$CODE"; const char $ENDE[] = "$ENDE";

Unification of Strings

by in CodeSOD on

As a general rule of thumb, when you see a class called StringConverter you know something is going to be wrong in there. That's at least what Erik thought when examining a bug in a totally different section of string handling code that just happened to depend on StringConverter.

StringConverter might sound like some sort of utility belt class with a huge pile of methods in it, but no- it's only got two. So we should take a look at both.