Code that is no longer used or needed.
TL;DR: Do not keep code "just in case I need it".
- Maintainability
- Remove the code
- KISS
- Gold plating code or Yagni code.
class Robot {
walk() {
// ...
}
serialize() {
// ..
}
persistOnDatabase(database) {
// ..
}
}
class Robot {
walk() {
// ...
}
}
Coverage tools can find dead code (uncovered) if you have a great suite of tests.
- Avoid metaprogramming. When used, it is very difficult to find references to the code.
- Unnecessary
Remove dead code for simplicity. If you are uncertain of your code, you can temporarily disable it using Feature Toggle. Removing code is always more rewarding than adding.
Photo by Ray Shrewsberry on Pixabay
This article is part of the CodeSmell Series.