| « Prev | Page 1 | Page 2 | Page 3 | Next » |
Re: But...Anything Can Happen!
2012-11-14 08:07
•
by
Doo-doo Facial Hair
(unregistered)
|
|
I just got terrible Excel flashbacks of functions with endless =IF(something;"OK";IF(something;"LESS OK";IF(something;"HELP SOS";IF(something;"NO WAIT IT'S OK";IF(etc...
And yes I know I was using Excel for something it was not really meant for but it was the only programming tool available (read: allowed) at the time. |
|
Damn, waited for years to write "First"... *Went to check my else if branch code for bugs*
|
|
anything can be frist
|
|
TRWTF is the happy ending. Bad developer gets fired?
Since this is in a safety critical industry, I feel better about airplanes and self driving cars already. CAPTCHA: ague - what I get from some of these stories |
|
Some coding standards (like, say, the ones used for C++ on the US Joint Strike Fighter program) specifically require an if/else if chain to be terminated with either an "else" handler or a comment that explains why there is no else. That seems like good practice for any software with significant safety implications.
|
Re: But...Anything Can Happen!
2012-11-14 08:22
•
by
Tom
(unregistered)
|
How about
Should be as good as the comment, if not better. |
|
// DO NOT make changes below this comment
if (frist) { doLameFristComment(); } else if (!frist) { doAnythingCanHappenComment("And probably will!"); } |
I don't understand this. Where are these new code paths? Is he talking about the possibility of some variable being undefined and therefore the IF and the ELSE IF both eval to false and neither block is executed? If so, TRWTF is using a loosely typed run-time language like JavaScript or PHP that allow undefined variables... especially in life-critical apps. Or, more likely, I've been mislead by Alex's brillant editing. |
Re: But...Anything Can Happen!
2012-11-14 08:37
•
by
Anonymous Will
(unregistered)
|
|
I think he means about when some variable is supposed to be assigned a different value in the 2 branches.
|
Re: But...Anything Can Happen!
2012-11-14 08:41
•
by
Karl
(unregistered)
|
Oh, come on! We can do better than that. How about: alert("Logic inconsistency error detected! After you click OK, this instance of the simulation will be terminated. You should awake in a similar universe where this never happened. In most cases people report no recollection of this event.\n\nOh by the way, if you tell anyone else, it makes timeline reintegration much more difficult. So don't do that."); |
Re: But...Anything Can Happen!
2012-11-14 08:43
•
by
long johnson
(unregistered)
|
|
if patient.sick? && !patient.dead?
heal patient else if !patient.sick? && !patient.dead? bury patient end |
|
Wow the process worked.
|
Re: But...Anything Can Happen!
2012-11-14 08:46
•
by
Justsomedudette
(unregistered)
|
That would be Mark's brilliant editing, but please don't let accuracy or spelling ruin a perfectly snide comment. |
|
You're right, anything could happen:
a = 10 |
|
if patient.sick? && !patient.dead?
heal patient else if !patient.sick? || patient.dead? if patient.dead? bury patient end end FTFY |
|
Re: But...Anything Can Happen!
2012-11-14 08:55
•
by
LoremIpsumDolorSitAmet
|
Just because Mark submitted it doesn't mean it didn't get preprocessed by the almighty Alex! Or maybe Mark is his sockpuppet. Or maybe they're just as brillant as each other. PS. 'brillant' is not a typo; you must be new here! |
Re: But...Anything Can Happen!
2012-11-14 08:55
•
by
Anonymous Cow
(unregistered)
|
The issue that they're referring to would come up if they changed this: if(a > 10) ...into this: if(a > 10) What happens if a is 10? |
Re: But...Anything Can Happen!
2012-11-14 08:56
•
by
masseyis
(unregistered)
|
Decades of experience in waiting to be frist |
Re: But...Anything Can Happen!
2012-11-14 09:04
•
by
stinkiemcslimey
(unregistered)
|
|
if (a)
{ dowork(); } else if (!a) { domorework(); } else { return(FILE_NOT_FOUND); } |
Re: But...Anything Can Happen!
2012-11-14 09:07
•
by
LoremIpsumDolorSitAmet
|
Yes, I understand how the terrible reverse-ifs resulted in "no fewer than ten bugs [being] created in the process". But that doesn't help me understand "creating code paths that did not assign these variables". |
Re: But...Anything Can Happen!
2012-11-14 09:09
•
by
Mike
(unregistered)
|
|
shouldn't it be
... else if !patient.sick? || patient.dead? ... |
Re: But...Anything Can Happen!
2012-11-14 09:13
•
by
Matthew
(unregistered)
|
int foo; |
Re: But...Anything Can Happen!
2012-11-14 09:16
•
by
Ben Jammin
(unregistered)
|
Think about it... then giggle. |
Re: But...Anything Can Happen!
2012-11-14 09:19
•
by
Kaso
(unregistered)
|
|
Re: But...Anything Can Happen!
2012-11-14 09:21
•
by
Ben Jammin
(unregistered)
|
Plus, if you're not sick, hopefully being buried isn't the solution. Obviously, patient.sick? needs to be a tri-state boolean of true, false, and LIFE_NOT_FOUND. |
Re: But...Anything Can Happen!
2012-11-14 09:23
•
by
Max
(unregistered)
|
An example in c++ would be: float x; if (x > 10) { } Defining x without initialising it to something (eg = 5.4f) means that it'll just contain the value of whatever was as that memory location. Could be any number, and results can change every time you run it. |
Re: But...Anything Can Happen!
2012-11-14 09:25
•
by
Meta-commentator
(unregistered)
|
|
Seeing a marginal WTF, expects great reams of meta commentary on the post about the failure. Meta commentary does not exisist.
So fail |
Re: But...Anything Can Happen!
2012-11-14 09:27
•
by
Ben Jammin
(unregistered)
|
Your example breaks an if/else as well as an if/else if. Refer to Kaso's. |
Re: But...Anything Can Happen!
2012-11-14 09:28
•
by
jonkenson
(unregistered)
|
|
I took that to mean that using this if - else if style would complicate things further up.
"Doug was a go-getter. He made the effort to go through the rest of the module and bring all the if/else statements into his if/else if "pattern"." So essentially using this style, he introduced bugs higher up in the code that trickled down to cause a RWTF issue in this code. |
Re: But...Anything Can Happen!
2012-11-14 09:28
•
by
Geoff
(unregistered)
|
|
Because if you convert if .. else, into if .. else if !(cond) and you screw up the !(cond) part suddenly you have code where neither the if clause nor the else clause gets executed where it would have alsways been the case at least one would have been run before.
|
Re: But...Anything Can Happen!
2012-11-14 09:28
•
by
Buffoon
(unregistered)
|
Something like that spells it out enough for you? |
Re: But...Anything Can Happen!
2012-11-14 09:29
•
by
Buffoon
(unregistered)
|
Fix... |
|
Elseif can be useful. But it can ended in a mess
|
Re: But...Anything Can Happen!
2012-11-14 09:40
•
by
Abico
(unregistered)
|
You've been misled into thinking that was the referenced typo. |
|
Works fine in Oracle pl/sql:
DECLARE a BOOLEAN; BEGIN IF ( a ) THEN DBMS_OUTPUT.PUT_LINE( 'true' ); ELSIF ( not a ) THEN DBMS_OUTPUT.PUT_LINE( 'false' ); ELSE DBMS_OUTPUT.PUT_LINE( 'null=> other universe?' ); END IF; END; Output: 'null=> other universe?' |
Re: But...Anything Can Happen!
2012-11-14 09:45
•
by
TheRider
(unregistered)
|
Don't you make me spit my coffee on the screen. Too much work cleaning it... |
|
Is doing nothing when a== 0, b >= 30 and c != null intentional? If not it somehow proves the point...
|
|
the correct construct is of course to first create a boolean of the condition.
|
|
Reminds me of another "experienced" developer, who'd always use the mouse to select items and then do copy&paste through the context menu. Another one of those valued developers with over a decade of experience ...
|
Re: But...Anything Can Happen!
2012-11-14 10:04
•
by
Nemo
(unregistered)
|
FTFY |
That was when Doug threatened Matt: "Now do sign off my changes OR ELSE ... do not sign off my changes!" |
|
if(i++ == 1){
doSomething(); }else if(i++ == 1){ doSomethingElse(); } |
|
It's probably late for this, but...
The real problem with if (condition) {...} elsif (reverse_of_condition) {...} end Is not that YOU might mess up your reverse_of_condition computation. We can assume that YOU are smart enough to use !(condition) for that. The real problem is that at some point condition will need to be modified. By someone who has never seen this code before. Who isn't as smart as you. That's what "doubled the complexity" meant. |
Re: But...Anything Can Happen!
2012-11-14 10:26
•
by
operagost
|
Just in case of FILE_NOT_FOUND in your boolean. |
Re: But...Anything Can Happen!
2012-11-14 10:31
•
by
chris
(unregistered)
|
IIRC it's the ANSI standard: null != null. Its the same in T-SQL (SQL Server) by default. One hell of an annoying convention. |
|
TRWTF is that he had decades of experience in VB
|
Re: But...Anything Can Happen!
2012-11-14 10:55
•
by
iusto
(unregistered)
|
Now you're exaggerating a little. If you had said, a guy scrolls up 2 pages of text to copy a short word so that he can paste it where he was below (to avoid typing it), then I'd understand. I noticed a couple of devs doing that for as little as 4-characters. Not to mention that IDE at the time was Visual Studio, where intellisense is present. |
Re: But...Anything Can Happen!
2012-11-14 11:04
•
by
DB
(unregistered)
|
HAHAHAAHAHHAA |
Re: But...Anything Can Happen!
2012-11-14 11:13
•
by
Paul Neumann
(unregistered)
|
Real developers have no mouse. Real developers have no keyboard. Real developers whistle at 900 baud to a modem attached to ttyS0! |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |