Another use for comments: to document the strategies you tried and why they failed. In other words not just the "why" but the "why not". Many times I've gone back to code I'd written previously, it seemed overly complicated, I replaced it with a simpler version... that failed... that reminded me that was what I'd tried originally and then replaced it with the more complicated version for a good reason. So now I have…
// // Dear maintainer: // // Once you are done trying to 'optimize' this routine, // and have realized what a terrible mistake that was, // please increment the following counter as a warning // to the next guy: // // total_hours_wasted_here = 42 //
// Dear maintainer,
// The code which follows was hacked together under desperate pressure.
// It's not smart. // It's not doing anything really subtle. // It's the only thing we could get to work in the time.
// If you want to chuck it and replace it, you absolutely should.