DEV Community

Cover image for Code Smell 09 - Dead Code
Maxi Contieri
Maxi Contieri

Posted on • Updated on • Originally published at maximilianocontieri.com

Code Smell 09 - Dead Code

Code that is no longer used or needed.

Problems

  • Maintainability

Solutions

  • Remove the code
  • KISS

Examples

  • Gold plating code or Yagni code.

Exceptions

  • Avoid metaprogramming. When used it is very difficult to find references to the code.

Sample Code

Wrong

class Robot {   
  walk(){
    //...
    }
  serialize(){
    //..  
  }
  persistOnDatabase(