You have version control. So use it!

How often do you see items like this when reviewing your source code:

//We no longer display the count on the homepage
//Uncomment this if we need it again! 8/20/2010
//for(int i = 0; i < maxResults; i++)
//{

or…

//Why is this commented? How are we getting the most active user now??
//comments.GroupBy(c => c.User).Select(c => c.Count()).OrderByDescending(c).First();

I see comments like these far too often… and I don’t know why! Leaving dead code in a source file causes many more problems than it solves.

The second code block is a prime example of this. Someone ends up seeing the commented code, wonders why it’s commented, wonders if it should be and wonders if whatever is using it is now broken as a result. That person then adds another comment asking why it’s commented so that someone, some time in the future can find it and possibly provide an answer. Some time in the future could be tomorrow, or next week, or 2 years from now. There’s no way to know, so the code sits in there until another person finds it and gets confused.

Any self respecting development shop uses version control. Your company most likely uses version control. So use it. If code is dead, remove it from the source file! If you ever need to get it back you can look through old revisions and find it.

Commenting code is killing code. And you know where dead code lives? In the revision history.