Dead code is code that is never run, that can never be reached.
Some manifestations of dead code include:
- Functions that are never called
- Variables that are written but never read
- Parameters passed to an internal method that are never used
- Enums, structs, classes, or interfaces that are never used
- Features removed from an application's user interface, but the backend support code is left in.
- Wizard-generated UI code that inserts hooks that are frequently never used.
- Remove dead code wherever possible. It gets in the way and slows you down.
- It is safe to remove code that you might need in the future. You can always get it back from version control.
- Code cleanup should always be made in separate commits to functional changes.
- Dead code happens in even the best codebases. Tell your code to get a life, or get lost.