12 ms·
On the flip side, I’ve had things like: // in case this is malformed, fix formatting so it will still parse input = fixInputFormatting(input); and had
by dhosek 4y ago
On the flip side, I’ve had things like:
// in case this is malformed, fix formatting so it will still parse
input = fixInputFormatting(input);
and had a code reviewer ask, “why are you calling fixInputFormatting”?
Nothing to raise the blood pressure like a code review question that is literally answered by a comment on the line immediately preceding where they left the question.
- wizofaus 4y agoBut in this case surely you're better off with input = fixInputFormattingIfMalformed(input); or even if (isMalformed(input)) input = fixInputFormatting(input);
- scatters 4y agoI'm with the reviewer on this one. Why is it malformed? Why are you fixing it here and not earlier? Why are you fixing it and not rejecting it? The comment tells me nothing.
- dhosek 4y agoI don’t remember the exact comment/cope pair anymore, but it was something that the answer they wanted was exactly what was on the preceding line. Coming up with a simple example to demonstrate that is a surprisingly hard thing to do.