- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
My frist thought (the comparison error aside) is that the coder just knew that decision would be reversed and coded in anticipation of it.
Admin
Thus ends today's lesson about why strongly typed languages with validating compilers are so valuable.
Admin
Yeah, yeah, Ulysses removed the conditional, but kept which branch?
Admin
Well, that was obviously tested really carefully now, wasn't it?
Admin
candidateNum=4 if candidateNum == "4": handleCandidate3() return true else: handleCandidate4() return true
Admin
Four not found?
Admin
candidateNum=4; return [handleCandidate3,handleCandidate4]sum([candidateNum==candidateLogic for candidateLogic in ["4",'4',[4],(4),{4},4]]) or True
There, now it's improved(!) and only takes one line :)
Admin
Happily coercing the types which do not exist silently, eh?
Admin
(4) is equivalent to 4. You really wanted to use the 1-tuple (4,) instead.
Admin
something something there is no four, thou shalt go directly from 3 to 5.
Admin
This mistake is understandable (well, outside of "why not just remove the conditions", though we've all been there and the answer is probably "for when the client changes their mind back in a week)....but I'll never understand how this gets passed testing. How vital can this change have been if no one noticed that instead of always doing 4 it never did 4?
Admin
Testing? What's that?
Admin
Perhaps it was working as intended, where handleCandidate4() is the one that should never be called, and handleCandidate3() should always be used; but the developer thought it would be funny (or something) to make the code confusing.
Admin
"JavaScript has no type system"
Well, that explains the "typeof" and "===" operators.
Admin
Been there. Done that. And they did ask for it to be changed back the next month.
Admin
I like to handle these by putting a bit mask in the config file:
<add key="InstanityLevel" value="10" />Then you can compare later in your code:
if (InsanityLevel & 2) { // do something insane } else { // do something sane }
Admin
For reference: http://scholar.harvard.edu/files/mickens/files/towashitallaway.pdf In particular the section that begins:
For example, it would definitely be horrible if your browser’s scripting lan- guage combined the prototype-based inheritance of Self, a quasi-functional aspect borrowed from LISP, a structured syntax adapted from C, and an aggressively asynchronous I/O model that requires elaborate callback chains that span multiple generations of hard-working Americans. OH NO I’VE JUST DESCRIBED JAVASCRIPT. What an unpleasant turn of events! People were begging for a combination of Self, LISP, and C in the same way that the denizens of Middle Earth were begging Saruman to breed Orcs and men to make Uruk-hai.
Admin
(That was the joke, and it's kind of an improvement because it doesn't fail silently by taking the wrong branch. Of course, the error would be harder to fix once discovered.)
Admin
No matter which candidate they asked to handle, they get trumped.
Admin
Oops, did I just say that? Oh no. I survived everything else up to here, and now Hillary's going to kill me.
Admin
Hey, what hacker leaked our STATE SECRETS onto the Internet? I'm going to sue you guys.
Admin
I like how the author admits he is terrible at JS, and probably at programming in general as well.
Admin
By this time
handleCandidate4
andhandleCandidate3
probably do the same thing anyway.Admin
TRWTF is that they were ever supposed to be different.
Admin
Am I the only one who read
towashitallaway.pdf
as
tow a shit all away
?