Steve D. has the pleasure of working with an attritioned[1] senior programmer; you know, the guy who not really a great programmer, and definitely not management material, yet who's been there so long that he's somehow attained a "senior" title. Since none of the project leads want him developing new code, the senior programmer (we'll call him Jed) has taken up a "quality" role. Jed will browse through the project teams' code and write up recommendations on how to improve the quality.

Every once in a while, Jed will take it upon himself to "tidy up" the code and fix things. Steve noticed his validation unit tests were failing one day, and soon realized that he was victim to Jed's quality assurance. In addition to all 250+ opening curly braces being moved to the same line as the method/if/while statement, the argument validation was just no longer working.

The "before" version ...

/* Validate Arguments */
if ((expansionRate) < 1 || (expansionRate) > 6)
  throw new ArgumentOutOfRangeException ("expansionRate","must be between 1 and 6 inclusive");
if ( (expansionRate == 1) && (partCoefficient == 1) )
  throw new ArgumentException("if expansionRate is 1, partCoefficient cannot possibly be 1");
//ED: Snip
if (calcMod == null)
  throw new ArgumentNullException("calcMod");
if ((threshold) <= 0 || (threshold) >= 1)
  throw new ArgumentOutOfRangeException("threshold","must be between 0 and 1");

And the "improved" version ...

/* Validate Arguments */
int invalidArgs = 0;
if ((expansionRate) < 1 || (expansionRate) > 6) invalidArgs ++;
if ( (expansionRate == 1) && (partCoefficient == 1) ) invalidArgs ++;
//ED: Snip
if (calcMod == null) invalidArgs ++;
if ((threshold) <= 0 || (threshold) >= 1) invalidArgs ++;

if (invalidArgs==12)
  throw new ArgumentException("Invalid Arguments.");

[1] Yes, attritioned is a word. Look it up.

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