Dead Code


Symptoms

  • A variable, parameter, field, code fragment, method, or class is not used anywhere (perhaps other than in tests).

Causes

  • Requirements have changed, or new approaches are introduced, without adequate cleanup.

  • Complicated logic results in some combinations of conditions that can't actually happen; you'll see this when simplifying conditionals.

What to Do

  • Delete the unused code and any associated tests.

Payoff

Reduces size. Improves communication. Improves simplicity.

Contraindications

  • If your application is a framework, you may have elements present to support clients ' needs that, strictly speaking, aren't needed by the framework itself. For example, a class may have an empty hook method intended to be called by (not-yet-existing) subclasses.

Notes

This smell can be hard to detect without tool support. Once your suspicions are alerted, you can do things like a global search for new ClassName .



Refactoring Workbook
Refactoring Workbook
ISBN: 0321109295
EAN: 2147483647
Year: 2003
Pages: 146

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net