3 ms·
I tend to agree with the OP, the problem is not the braces per se. IMO, better would be a coding convention to skip curly braces but if and only if the entire i
by paul_f 13y ago
I tend to agree with the OP, the problem is not the braces per se. IMO, better would be a coding convention to skip curly braces but if and only if the entire instruction is on one line. Then the bug would have stood out more prominently.
- SideburnsOfDoom 13y ago> IMO, better would be a coding convention to skip curly braces but if and only if... IMHO, even better and simpler would be a coding convention to not skip curly braces. The end. (as per last time this was raised: https://news.ycombinator.com/item?id=7283767 https://news.ycombinator.com/item?id=7283767 ) Otherwise, the OP is right on the money; there are multiple levels that would have caught this bug - a layout convention, a linter, a code review, pairing, a unit test, an integration test. Or just a refactor of the big old method for clarity.
- vkjv 13y agoThis. In addition, a linter would have caught his example with braces because of the improper indent. And, IMHO, without that indent it becomes glaringly obvious.
- SideburnsOfDoom 13y ago> This. In addition, a linter would have caught his example with braces because of the improper indent That and the dead code after it.