I never delete code - only comment them
visualstudiomagazine.comThis is f-ing terrible. Put your code into version control and stop having it be bad, for goodness sake.
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?
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.
Sorry I don't agree with this. I delete code all the time. The difference is, when I write elegant code that I am proud of I save it. The majority of code I write is utility not elegant by comparison. This is like my art, or any art.