Programming Mistake Patterns And How To Avoid Them

Un-used Re-factorings

Before:

  foo(big + wide + long + expression, blah);

Intended:

  expr = big + wide + long + expression;
  foo(expr, blah);

Mistake:

  expr = big + wide + long + expression;
  foo(big + wide + long + expression, blah);

Impact: Initial code may pass testing, but future additions to one expression copy or the other is out-of-sync with the other, resulting in the change not showing up or misleading code.

Possible solution: A code analysis tool that warns of un-referenced variables.


CategoryCodingIssues


EditText of this page (last edited December 22, 2009) or FindPage with title or text search