This may be better in the polling booth, but I'm curious what you all think about or have experienced (and I want to vent a little). First the question, then the venting.
Is it good or bad to leave commented-out code in production? Why?
I think it is bad. Why? In the code-maintenance phase, it's often difficult enough to figure out the intent of the executing code. The difficulty is compounded if you have to sort through code that was executing at one point in time.
I've seen this where I work, and it annoys, frustrates, sometimes confuses me, for the reason cited above. (If you ever work with me on any project an notice me doing this, slap me. :-)
Update: It looks like there are more votes for "it's bad" than for "it's good", which makes me :-). perrin, followed by others, mentioned one (and in my opinion, after considering it, the only) justifiable reason for leaving in commented-out code:
...leave it in commented out with a note saying "This looks like it should work, but it doesn't because XYZ." That could save other coders from duplicating this effort.
(My emphasis added.) I like dragonchild's idea even better: instead of commenting out blocks of code, remove the code, and put the algorithm that didn't work in the comment.
And now to possibly offend some of you, I don't agree with the "leave functionality commented out now that the users may ask for later" argument. My experience has been that by the time the user asks for the functionality I thought would "be cool" to have, what they're asking for is different enough to justify a re-write of what I was thinking the first time through. Sorry...
Still, the famous clause "it depends" applies in this case too. (That's been the ultimate answer to several of my posts. :-)
In reply to Commented out production code? by t'mo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |