9 ms·
His code example is: if (error_of_fifth_kind) goto fail; goto fail; if (error_of_sixth_kind) goto fail; The_truly_important_code_handling_n
by darrencauthon 12y ago
His code example is:
if (error_of_fifth_kind)
goto fail;
goto fail;
if (error_of_sixth_kind)
goto fail;
The_truly_important_code_handling_non_erroneous_case
My question: If the "truly important code" is really that important, where are the unit tests to verify that it "handles" the "non erroneous case????"
Test. Your. Code.
- loumf 12y agoI agree that it's totally shocking that Apple did not have an example of each kind of bad cert. Even a rudimentary unit test of this code would have caught this bug. I bet they do now.
- leephillips 12y agoBut rudimentary testing of critical code is not part of Apple's corporate culture. They have released versions of the Finder with amateurish bugs that delete files[1] and versions of Mail that randomly delete messages[2]. Several versions of Mail on iPhone, a couple of iOS versions ago, send hundreds of copies of a message when emailing a link from Safari[3]. They've chosen to hoard over a hundred billion dollars in cash rather than hiring more competent engineers and enforcing quality control. The blame for these fiascos, and for the goto fail bug, getting out the door lies not with the programmers, who can not avoid making mistakes, but the with the CEO and other management, who decide how to allocate resources. [1]http://tomkarpik.com/articles/massive-data-loss-bug-in-leopa.. http://tomkarpik.com/articles/massive-data-loss-bug-in-leopa.... [2]http://discussions.apple.com/thread.jspa?messageID=12758081&.. http://discussions.apple.com/thread.jspa?messageID=12758081&.... [3]http://lee-phillips.org/iphoneUpgradeWarning-4-2-1/ http://lee-phillips.org/iphoneUpgradeWarning-4-2-1/
- loumf 12y agoThe thing that kills me is that rudimentary unit testing of simple functions like this makes development faster. You have to run the code, right? It's easier to run it in a unit test than to set up an environment to run the result. My pet peeve is code that is so broken that it has obviously never even been run.
- dragonwriter 12y ago> My pet peeve is code that is so broken that it has obviously never even been run. Yeah...in my first support job I had to deal with a customer call that traced back to a install script for our company's (quite pricey, enterprise back-end) software dying with a syntax error.
- sparkie 12y agoAlso: just because you can omit braces, doesn't mean you should. Stick to 1TBS and this kind of mistake shouldn't happen.
- usefulcat 12y agoAgreed, but the author's point (indirectly, perhaps) is that requiring braces is an example of something that should be part of the language, and the fact that it's not should be considered a defect of the language.
- darrencauthon 12y agoThis mistake shouldn't happen? Mistakes always happen. Even if I dedicated myself to using braces everywhere, my mistake might be that a) I put the braces in the wrong place, or b) I forgot to put the braces.
- Jtsummers 12y agoShouldn't != couldn't. In Haskell and the MLs, for instance, certain classes of mistakes shouldn't happen because of the type system and pattern matching, but a single wildcard could throw that off.
- Jtsummers 12y ago1TBS = One True Brace Style, had to look up that abbreviation [1]. Puts the `{` on the line with the `if`, `for`, `while` text and the `}` on its own line, and requires the braces even for one line blocks. (I knew the rest, just hadn't seen "1TBS" before.) [1] http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS
- mikestew 12y agoBecause Apple doesn't have a software testing culture. At least that's what I've been told by Apple engineers I know who used to work at Microsoft ("software testing is not the same respected discipline you're used to at Microsoft"), as well as when I interviewed with Apple and asked what kind of test team would be backing the product I would be working on (manual testing with no SDETs, apparently). Take it as the quite anecdotal evidence it is, but to me it explains a lot.