3 ms·
"And then, the code changes but the comment doesn't. Now its downright misleading." Sorry, that's just a failure of the programmer, same as any other coding mi
by ShirtlessRod 15y ago
"And then, the code changes but the comment doesn't. Now its downright misleading."
Sorry, that's just a failure of the programmer, same as any other coding mistake they may make. It is by no means a reason to not have comments.
- JoeAltmaier 15y agoDisagree! Disagree! Having essentially the same code written in two places (code and comment) absolutely BEGS for them to get out of sync. Its why we write modules, subroutines etc - get it right once. Comments are evil if they mention the code. They should be about constraints, the compiler, your wife, ANYTHING but the code.
- ShirtlessRod 15y agoI didn't say the comment had to be describing the code in terms of what it was doing, but it absolutely should describe why something was done. If that "why" changes, then the comments should be updated. This isn't double documentation -- it's complementary documentation. Code is the what, comments are the why. If one does not match the other, then again, that's on the programmer.