2 ms·
Pedantic but a comment clarifying the unit of measurement belongs with the declaration of the variable, not an increment statement.
by vunderba 2y ago
Pedantic but a comment clarifying the unit of measurement belongs with the declaration of the variable, not an increment statement.
- tialaramex 2y agoThe problem, in this case, is that the correct size of the increment involves the unit of measurement. If we change the unit of measurement and go update your comment on the declaration of the variable, now everywhere which uses the variable is wrong. int time; // in seconds /* thousands of lines away or in another file */ time += 1; Later we change the time to be in milliseconds. We update the comment on the declaration, but now that code is wrong and we have no reason to know that. That's a bad choice, languages should do better (and some do - where they do, use the better features and this problem vanishes) but when it's forced upon us it makes sense to either put the unit in the name of the variable or ensure comments about changes to the variable explain the units consistently, even though that's lots of work. This extra work was dumped on you by the language.