cover-img

Code Smell 09 - Dead Code

Code that is no longer used or needed.

24 September, 2022

4

4

1

TL;DR: Do not keep code "just in case I need it".

Problems

Maintainability

Solutions

Remove the code

Examples

Gold plating code or Yagni code.

Sample Code

Wrong

Right

Detection

Coverage tools can find dead code (uncovered) if you have a great suite of tests.

Exceptions

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

Tags

Unnecessary

Conclusion

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.

More info

Credits

This article is part of the CodeSmell Series.

software

javascript

programming

cleancode

4

4

1

software

javascript

programming

cleancode

Maxi Contieri

Buenos Aires, Argentina

🎓Learn something new every day.📆 💻CS software engineer 👷coding👨🏽‍🏫teaching ✍🏾writing 🎨Software Design 🏢SOLID 🌉TDD 👴Legacy 💩Code Smells

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2024. Showcase Creators Inc. All rights reserved.