Hacker News new | ask | show | jobs
by jon2512chua 4456 days ago
Good read. But regarding deleting commented out code, I have always have a strong aversion to doing so even though I really want to, for fear that someone somewhere might want it.

Has anyone ever faced this dilemma before? If yes how did you guys dealt with it?

6 comments

I always think: the code can be found in the repository somewhere. So if we need it later, we still have it. But in the production the commented out code it is just confusing.
I agree with antonpirker here. As long as you're using a version control system, the code isn't lost. Delete the commented out code, and leave a helpful commit message along with the deletion. That way the deleted code can be found, if really necessary.
Major do'h moment for me. :P Got so used to using a VCS that I took some things for granted.
Are you using a version control system? Of course you are. This means that you can (relatively) safely delete anything you want in the working directory, because you can go back and retrieve older versions from the VCS.
I keep the code if it helps me understand the code that remains. I always try to write code that is simple, but sometimes other consideration (speed) mean that I have to turn easy to understand code into something that is not. Keeping the original code can help me understand what the new code is supposed to be doing.
Yes, I had the same issue and commented out the code instead of deleting it. Then I started using Git, started deleting the code instead and have never looked back.
If I have stuff like that, I often add a date to the comment. If its not been used in 6 months and i see it again, I'll usually delete.