Skip to content

Comment on Reflections on Curly Braces – Apple’s SSL Bug and What We Should Learn From It

Comments

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.

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 )

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.

This. 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.

This. In addition, a linter would have caught his example with braces because of the improper indent

That and the dead code after it.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.