3 ms·
I've never understood this argument for always including braces in one-line if-blocks. Won't this error be immediately obvious? I mean, after making the change,
by dionidium 16y ago
I've never understood this argument for always including braces in one-line if-blocks. Won't this error be immediately obvious? I mean, after making the change, won't even the most minimal test catch the mistake?
If developer #2 isn't doing the most basic test to verify that "statement2" runs when "conditional" is true, then you've got way bigger problems than your style guide.
- mustpax 16y agoAnecdotally I've seen smart and capable developers make this mistake numerous times. It usually gets caught by code review, automation etc. But not always. It's basically the birthday paradox. You take the probability of a very unlikely event and raise it to a big enough power (enough people, enough lines of code) it becomes a non-negligible outcome.
- mathgladiator 16y agodeveloper #2 probably doesn't care because it passes the unit tests and no one is the wiser. I've seen a lot of bugs during some consulting work that was simply the result of either intellectually laziness or un-disciplined coding.
- gte910h 16y ago> Won't this error be immediately obvious? No, smart people miss it all the time.