Throw it away!

Unused code the worst kind of technical debt. It's like paying interest on a loan after you've already declared bankruptcy.

I was reminded again recently of the importance of deleting unused code.

One of the clients I’m working with is struggling to update some of their ancient third-party dependencies in a rather large, poorly-understood codebase.

We identified a useful strategy to reduce the scope of the task: Let’s remove some unused features!

The good news was, we had a pretty solid list of known features that had been sunsetted. So we set out to start pulling these unused features apart from the rest of the code, so they could be deleted.

Then we discovered huge swaths of code that was simply unused.

A minority of this unused code looks to have never been fully implemented, as evidenced by the empty methods and TODO comments.

But the majority of this unused code appears to be fully functional REST controllers, job queue workers, etc… that just aren’t hooked up to anything. My theory: When these features were sunsetted, the facade was removed. They were removed from the routing table, for example. But never actually removed.

This means that for what has likely been at least two years, thousands of lines of code has been sitting in this code base, never executed, but consuming time for compilation, running tests, linting, and even making routine changes.

Man, what a waste! This is literally the worst kind of technical debt. It’s like paying interest on a loan after you’ve already declared bankruptcy.

Don’t forget to delete your unused code!

Share this