DEV Community

loading...
Cover image for Code Smell 54 - Anchor Boats

Code Smell 54 - Anchor Boats

mcsee profile image Maxi Contieri ・1 min read

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

Right

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

Exception not Found

Wikipedia

Credits

Photo by Kris Mikael Krister on Unsplash


It is very hard to predict, especially the future.

Niels Bohr

Discussion (2)

pic
Editor guide
Collapse
dakujem profile image
Andrej Rypo

Why "Anchor Boats"? 🤣
"Dead Code" was not catchy enough?

I like this series btw.

Collapse
mcsee profile image
Maxi Contieri Author

They are different smells. The name is not mine