Code Smell 54 - Anchor Boats

Subscribe to my newsletter and never miss my upcoming articles

Code is there. Just in case. We might need it soon.

Problems

  • Complexity

  • Coupling

Solutions

  1. Remove dead code.

  2. Leave covered and real tested code.

Sample Code

Wrong

Detection

Using some mutation testing variants we can remove the dead code and see it test fails.

We need to have good coverage to rely on this solution.

Tags

  • YAGNI

Conclusion

Dead code is always a problem.

We can use modern development techniques like TDD to ensure all code is alive.

Relations

More info

Credits

Photo by Kris Mikael Krister on Unsplash

Thanks to Apoorv Tyagi for pointing this out.


It is very hard to predict, especially the future.

Niels Bohr



This article is part of the CodeSmell Series.

Comments (1)

Apoorv Tyagi's photo

Great article yet again :)