Comment on Reflections on Curly Braces – Apple’s SSL Bug and What We Should Learn From ItComments−ZoFreX12yI would also add:* For critical code, enable as many compiler warnings as you can while remaining sane. This would definitely include unreachable code warnings.* Consider using static analysis* Initialise your error variable in the "error" state not in the "everything is ok" state−drone12yHere's one more to add:* Stop copying and pasting the same code over and over. If you do a complex series of operations several times, encapsulate them in a function/method.−EvanAnderson12yI came here to make your third point. I feel strongly that code should be written to "fail safe"-- error state should be assumed until calls return otherwise, etc.
Comments
I would also add:
* For critical code, enable as many compiler warnings as you can while remaining sane. This would definitely include unreachable code warnings.
* Consider using static analysis
* Initialise your error variable in the "error" state not in the "everything is ok" state
Here's one more to add:
* Stop copying and pasting the same code over and over. If you do a complex series of operations several times, encapsulate them in a function/method.
I came here to make your third point. I feel strongly that code should be written to "fail safe"-- error state should be assumed until calls return otherwise, etc.