Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Is Code Deletion Helpful?
3 points by vedant_ag on Sept 30, 2022 | hide | past | favorite | 6 comments
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.



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.


I should add, it's not typically done (from my exp) as a bespoke task. Sometimes "delete this endpoint" but often it's just a matter of refactoring.


So teams pick up some refactoring tasks in the sprint (from time to time), and it usually includes code deletion?

This makes sense.


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.


How often (say what % of PRs) do teams end up doing it?


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: