Poor man's comments.
If 1 = 0 ThenIs nameString empty?
...
End If
if (nameString + "x" != "x") {Hmm, is the comment wrong, or the code?
...
}
// Comma-separated list of numbers
string configurationIds = "254:762:2:236:23:5:21";
If 1 = 0 ThenIs nameString empty?
...
End If
if (nameString + "x" != "x") {Hmm, is the comment wrong, or the code?
...
}
// Comma-separated list of numbers
string configurationIds = "254:762:2:236:23:5:21";
3 comments:
Worth a CodeSOD entry in www.thedailywtf.com
Well the first is actually a pretty normal thing to do in languages that have no block comments (like ASP web pages). You might think that it would be nicer to write "if false then" in that case, but it's far easier to turn the block of code on and off by changing just one number than by deleting "false" and typing "true" ;)
And the second can be found a lot in shell scripts where actual textual substitution of variables might be done before the code is parsed, so if nameString was empty the code would be turned into something like:
if ( != '')
which would be a syntax error. So it's normal to write something ugly as:
if (nameString 'x' != 'x')
because in most shell scripts you don't need the + for joining strings this is actually valid regardless if nameString is empty or not.
It might be that this is a shell programmer that went on to Java or C# but still has to unlearn some of his old habits ;)
the nameString one made me snort
Post a Comment