Timur's Blog
... on life, software engineering and human languages

Delete unused code

November 5, 2022

Please, remove unused code as soon as it becomes unused.

No, this code will not save time or effort in the future. Because it will never be needed again.

Requirements change; the code has to reflect that. Keeping an old, unused code is akin to hoping that the exact requirements from the past will be needed again. It doesn't seem wrong ("what happened once will happen again"), but, in practice, I've never seen anything like this. And even if the stakeholders do change their minds again quickly, and even if the newest requirement is kind of similar to what was in the past, there is certainly going to be a twist that would make code reuse impractical.

And even if a true 180-degree reversal happens: the old code should still be in the version control system. Some git archeology and it's back alive!

The only thing that the old, unused code will ever do is make the future developer's life harder. It will be harder for them to navigate around the project. It will be harder to debug some weird issues that eventually pop up. It will be harder to refactor. It will also be harder to add more stuff. And no one, not a single human being, will ever say "thank you" for keeping that code. No one will ever find it useful.

The moment code becomes useless, simply delete it. For the greater good.

© Copyright 2022 Timur's Blog. Powered with by CreativeDesignsGuru