Many times, when we get a submission of bad code, we’re left wondering, “what else is going on here?” Sometimes, you think, “if only I knew more, this would make sense.” More often, you think, “if I knew more, I’d be depressed,” because the code is so clearly bad.

For example, Devan inherited a report, built using SQL Server’s Reporting Services Report Builder tool. Now, this tool is not intended as much as a developer tool, as a “if you can use Excel, you can make a report!” It uses Excel-style functions for everything, which means if you want to have branching conditional logic, you need to use the IIF function.

Just don’t use it like this.

IIf(Location_Id='01111','Location 1',
  ......
IIf(Location_Id='99999','Location Help Me','This was the Easy one')))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) )))))))))) ))))))))

Now, there’s a lot missing here, but we can infer what was skipped, simply by counting the brackets. Even LISP would be embarrassed by those parentheses.

In a different example, Phillip E. was reviewing the day’s check-ins, when he noticed this particular bit of VB.NET code:

Public Class UserSession
  Inherits UserSession(Of UserSession)
...
End Class

Honestly, I’m not 100% sure if this is a problem with the code, or the fact that the language lets you abuse names so badly. Then again, the Of UserSession is a type parameter, so I think we can still blame the developer who wrote this.

Angela A wants us to know that misleadingly named constants to replace magic numbers will always be a thing.

const float ZERO = 0.01f;

Taking all of these examples together, Jack S provides a perfect summary of how I feel about this code, this fragment coming from Classic ASP.

function die(s)
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!