Dead Code


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


  • 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.


Reduces size. Improves communication. Improves simplicity.


  • 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.


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

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: