HACKER Q&A
📣 vedant_ag

Is Code Deletion Helpful?


There is a lot of online literature about the benefits of deleting stale/unreachable code.

But in practice, do teams actually do this regularly? More importantly, does your manager recognise this as "work"?

Or does it mean: code deletion is good when other people so that I don't have to but I don't invest my time into it? Like technical documentation.


  👤 john_the_writer Accepted Answer ✓
It's 100% a good thing..

Most places I've worked (> 20 years) regularly delete dead code. Not all the time, but often enough that it's not a problem.

Tech docs on the other hand seem to still kick around. Mostly I read the Tests these days. This tells me the why, and how better than any doc I've ever seen. And they're up to date.


👤 moasda
I've had a lot of discussions with developers on this topic. It seems to be difficult for developers to delete code even if it is versioned in Git, so the code is not really lost.

I regularly encourage my teams to delete code that has no use in the near future. Because every line of code in the production environment leads to maintenance effort, so this would save their time.


👤 muzani
It's definitely a good thing. I categorize it under documenting. But while it costs time to read documentation and comments, it saves time on reading code that isn't stale. If you don't do it regularly, Chesterton's fence becomes crippling.