Live data from Hacker News

I never delete code - only comment them

visualstudiomagazine.com

1–6 of 6 posts

Re: I never delete code - only comment them

#3
There are times when this is required. For instance, where I find there is a line of code that shouldn't be called. Commenting it out and explaining that it breaks so and so is preferable to deleting it all together because there is a risk another developer will make the same error too.

Re: I never delete code - only comment them

#5
post #4

I've seen one reason to keep old code in: if the new implementation is complicated and the old one is short and simple, keep the old one as documentation for how the new one essentially works.

This is exactly what I do when writing complex code, and is about the only reason that I can think of to comment out code like this. The other time that I might do it is when I'm trying a couple of implementations to see which one is better.

But leaving commented out code in there is just asking for trouble. What happens when someone comments it back in 6 months later?