3 ms·
I try to never write a comment about anything that I've already written in code. I only add information that is necessary to know to run the code but is not in
by timdaub 5y ago
I try to never write a comment about anything that I've already written in code. I only add information that is necessary to know to run the code but is not in the code.
I do it like this as I think that conceptually duplicating code logic through e.g. comments can be dangerously imprecise. E.g. when someone changes the code (and not the doublicating comment), there are no checks in place for this mismatch of code and comment to be caught by e.g. a test.
- jbay808 5y agoIf you have really good test coverage that might be okay, but otherwise, how do you know if the code is doing what it's intended to do? If I see a line that looks like it might be a bug, or an unnecessary duplication, how do I know if it's a mistake or not?