Comment On Why Indeed

Having just inherited a mammoth, ASP-based ecommerce application created in a developmestuction by a handful of different consultants over several years, Ryan Davis found himself asking one question, over and over: why? [expand full text]
« PrevPage 1 | Page 2Next »

Re: Why Indeed

2008-11-26 08:03 • by ParkinT
Forty-Two

Re: Why Indeed

2008-11-26 08:07 • by Bob (unregistered)
--in why.txt-
/comment.asp:15 if not comment_id <> 0 then echo "WTF!"

Re: Why Indeed

2008-11-26 08:07 • by akatherder
This is not a comment... NAHT.

Re: Why Indeed

2008-11-26 08:09 • by akatherder
231024 in reply to 231022
Bob:
--in why.txt-
/comment.asp:15 if not comment_id <> 0 then echo "WTF!"


/comment.asp:15 if not comment_id <> 0 then echo !false

Re: Why Indeed

2008-11-26 08:10 • by amok (unregistered)
231025 in reply to 231024
/comment.asp:15 if not comment_id <> abs(0) then echo !false

Re: Why Indeed

2008-11-26 08:14 • by Andy Goth
I'm not not licking toads.

Re: Why Indeed

2008-11-26 08:22 • by A Nonny Mouse
why not?

or, in keeping with the double negative in the logic, why not not?

Re: Why Indeed

2008-11-26 08:24 • by luctus (unregistered)
231030 in reply to 231029
A Nonny Mouse:
why not?

or, in keeping with the double negative in the logic, why not not?

Why (! (not not))

Re: Why Indeed

2008-11-26 08:25 • by Zecc
I could ask the same thing.

In recently found the following (formatted as is):
if(somevar == 'some text') {} else {

// code
}

Re: Why Indeed

2008-11-26 08:29 • by Peter (unregistered)
Maybe the answer was in the other 64 bytes.

Re: Why Indeed

2008-11-26 08:32 • by Wyrd (unregistered)
" /cart/checkout.asp:15 if not contact_id <> 0 then "
Poignant, man. Very poignant.

"...and crawling on the planet's face... some insects called the human race... lost in time... lost in space... and meaning..."

--
Furry cows moo and decompress.

Re: Why Indeed

2008-11-26 08:39 • by imu (unregistered)
Neophytes. Clearly they forgot to declare constants for TRUE and FALSE.

Re: Why Indeed

2008-11-26 08:44 • by AndrewB (unregistered)
So the WTF of the day is that somebody once wrote a double negative? What about the rest of this guy's code? Is this really substantial?

Re: Why Indeed

2008-11-26 08:44 • by Arild (unregistered)
This appears to be the result of a find-in-files operation, listing the file, line-number and the line containing the text searched for (possibly "contact_id"?)

Re: Why Indeed

2008-11-26 08:45 • by cthulhu (unregistered)
not not not FileNotFound. brilliant!

etc

something about my captcha being relevant at a stretch even though it isn't.

etc

Ok think I have covered it all. No need for you to post that "witty" comment now.

Re: Why Indeed

2008-11-26 08:53 • by Synchronos (unregistered)
Aah, yes, I see it!

The correct form would be: if isTrue(not contact_id <> 0) then

Re: Why Indeed

2008-11-26 08:58 • by NeoMojo (unregistered)
231044 in reply to 231037
AndrewB:
So the WTF of the day is that somebody once wrote a double negative? What about the rest of this guy's code? Is this really substantial?
Them someone else put that particular line of code in a text file, probably while crying and pulling their hair out, then our submitter found the file. I'd say it's a representative line.

Re: Why Indeed

2008-11-26 09:15 • by Erasing History (unregistered)
Oh, c'mon Alex, that was the funniest comment of this motley bunch!

Re: Why Indeed

2008-11-26 09:22 • by Code Dependent
231049 in reply to 231035
Wyrd:
" /cart/checkout.asp:15 if not contact_id <> 0 then "
Poignant, man. Very poignant.

"...and crawling on the planet's face... some insects called the human race... lost in time... lost in space... and meaning..."
Each of us -- a cell of awareness
Imperfect and incomplete
Genetic blends with uncertain ends
On a contact_id search that's far too fleet

Re: Why Indeed

2008-11-26 09:22 • by jonnyq
231051 in reply to 231031
Zecc:
I could ask the same thing.

In recently found the following (formatted as is):
if(somevar == 'some text') {} else {

// code
}


Ok, that doesn't bother me as bad... I used to have a habit of things such as:
public $inactive;
with checks such as if(!$inactive)...
which is worse than if(is_true()) { } else { ... }
especially if the true condition could be filled in soon. Still not the prettiest, but could be worse

Re: Why Indeed

2008-11-26 09:26 • by Erasing History (unregistered)
I actually worked with a guy once who used and advocated the following design pattern:
if not a=b else ...

"for readability".

Always wondered how his brain was wired inside, that made him think this was more "readable".

Re: Why Indeed

2008-11-26 09:27 • by Charles400
231054 in reply to 231029
A Nonny Mouse:
why not?


That looks like COBOL. Better syntax:

!Y

Re: Why Indeed

2008-11-26 09:33 • by Alan (unregistered)
231055 in reply to 231035
[quote user="Wyrd"]" /cart/checkout.asp:15 if not contact_id <> 0 then "
Poignant, man. Very poignant.

"...and crawling on the planet's face... some insects called the human race... lost in time... lost in space... and meaning..."

Or should I say Dr Von not contact_id...

Re: Why Indeed

2008-11-26 09:47 • by Jim (unregistered)
That line is an artifact of using grep an misdirecting the output into a file by mistake

Re: Why Indeed

2008-11-26 09:51 • by mauhiz (unregistered)
Why ?

Re: Why Indeed

2008-11-26 09:52 • by !apoet (unregistered)
Ours is not to question why,
ours is but to code and die.

Re: Why Indeed

2008-11-26 09:56 • by DangerMouse9

DIM true AS string
DIM isTrue AS Boolean

true = "TRUE"

IF true = "TRUE" OR true = "True" OR true = "TRue" OR true = "TRUe" THEN
isTrue = True
ELSE
IF true = "TrUe" OR true = "TrUE" OR true = "TruE" THEN
isTrue = True
ELSE
'there could still be more instances where true can be true
IF true = "tRue" OR true = "tRUe" OR true = "tRUE" OR true = "tRuE" THEN
isTrue = True
ELSE
'I hate my life
IF true = "trUe" OR true = "trUE" OR true = "truE" THEN
isTrue = True
ELSE
'Do not need to check for the cases with upper command.
'If the upper doesn't = TRUE then it is not true
IF NOT upper(true) = "TRUE" THEN
isTrue = False
ELSE
isTrue = true
END IF
END IF
END IF
END IF
END IF

IF NOT (isTrue = False) THEN
DIM strComment AS String
strComment = "I am adding a comment. "
strComment = strComment + "This comment will be displayed"
strComment = strComment + " for all the world to see. "
strComment = strComment + "Well, at least those with "
strComment = strComment + "internet access and browsing "
strComment = strComment + "to this page."
AddComment(txtCommentBox, strComment)
END IF



Re: Why Indeed

2008-11-26 10:01 • by Code Dependent
231064 in reply to 231060
!apoet:
Ours is not to question why,
ours is but to code and die.
Into the bluescreen of death
Wrote the six hundred.

Re: Why Indeed

2008-11-26 10:25 • by halcyon1234
231068 in reply to 231040
cthulhu:
not not not FileNotFound. brilliant!

etc

something about my captcha being relevant at a stretch even though it isn't.

etc

Ok think I have covered it all. No need for you to post that "witty" comment now.


I think you mean "Not no need for you not to post that not unwitty comment now."

Re: Why Indeed

2008-11-26 10:30 • by DaveK
231069 in reply to 231057
Jim:
That line is an artifact of using grep an misdirecting the output into a file by mistake
Why should it be a mistake? People often direct the output of grep to a file on purpose, like because they might want to refer to it later, or if they think there might be aa awful lot of output. These files are transient in nature and often named according to the passing whim of the programmer, or whatever's foremost in their mind at the time; hence they are often given names such as "wtf.txt", "crap.log", "fuckfuckfuck.txt", "aaaarrrrrrggghhhh.txt" or "iamgoingtoFUCKINGKILLMICROSOFT.txt". Presumably "why.txt" is shorthand for "whythefuckdoesittestthisvariableandicantevenfuckingfindanywhereitevergetssetoranysoddingreferencetoitatallFORCRYINGOUTLOUD!.txt"


Ruby version

2008-11-26 10:31 • by Tuxie (unregistered)

unless not !(contact_id != 0) !== !true
return
else
process_cart
end

Re: Why Indeed

2008-11-26 10:33 • by Horamash (unregistered)
231071 in reply to 231068
halcyon1234:
cthulhu:
not not not FileNotFound. brilliant!

etc

something about my captcha being relevant at a stretch even though it isn't.

etc

Ok think I have covered it all. No need for you to post that "witty" comment now.


I think you mean "Not no need for you not to post that not unwitty comment now."


A nice example of Muphry's law there.

Re: Why Indeed

2008-11-26 10:40 • by ath (unregistered)
This is not a wtf. It's a koan written by a zen monk. In words: If something is not nothing, then there is nothing.

My brain has sure reached Nirvana after reading it...

Re: Why Indeed

2008-11-26 10:45 • by Qvasi (unregistered)
Sometimes (like sombodys example above about !$inactive), it's more intuitive to have a "double negative" (I ain't not talking about no English double negatives, I mean logical: NOT NOT).

But mentally parsing a series of NOT's is hard, that's why I really loved the ruby statement 'unless' wich is essentially an 'if not' but it somehow makes it less taxing on the brain. What I don't like so much about it is that you can't say:
unless somecondition do

#something
else do
#something else
end

Of course when you need both cases I should reverse it and use an if statement anywy.... but why not?

Re: Why Indeed

2008-11-26 10:56 • by Satanicpuppy
231074 in reply to 231031
Zecc:
I could ask the same thing.

In recently found the following (formatted as is):
if(somevar == 'some text') {} else {

// code
}


I see that sort of thing all the time. Originally there was actually something to DO if there was 'some text' (not just if there wasn't) and then there wasn't anymore, and it was easier to just delete that logic and move on than to actually change the terms of the conditional.

Re: Why Indeed

2008-11-26 11:01 • by Mr B
231076 in reply to 231073
Why didn't they use some off-the-shelf ecommerce site? Why aren't there any comments, anywhere?? Why did anyone let the original developer near a keyboard, let alone allow him to program!? Why did I even bother coming in today!?!?


1. Because it would have cost too much, done too much and the code probably wouldn't have been any easier to maintain and/or the maintenance costs would have been extortionate.

2. Commented code doesn't make it good code, it just makes it commented.

End Function // This is the end of the function.

^ I see that all the time. Good code should need very VERY sparse commenting, and only when there's a piece of specific business logic that could cause confusion should it be used, such as:

// This is the default <<system>> rounding.
return Convert.ToDecimal(Math.Round(Math.Abs(_investmentValue), 2, MidpointRounding.AwayFromZero));

3. Because they didn't know any better and didn't review the code, this is more a problem with management and the development process than the coder (as usual).

4. You came in today because they need you to fix the code. If the code worked and was easy to maintain, you'd be out of a job. You should be THANKING the original developer, not cursing them.

As for TRWTF, was that line still in checkout.asp? Did he not realise it was grep output? TRWTF is that we didn't find out what TRWTF was.

Re: Why Indeed

2008-11-26 11:04 • by Satanicpuppy
231077 in reply to 231073
Qvasi:
Sometimes (like sombodys example above about !$inactive), it's more intuitive to have a "double negative" (I ain't not talking about no English double negatives, I mean logical: NOT NOT).

But mentally parsing a series of NOT's is hard, that's why I really loved the ruby statement 'unless' wich is essentially an 'if not' but it somehow makes it less taxing on the brain. What I don't like so much about it is that you can't say:
unless somecondition do

#something
else do
#something else
end

Of course when you need both cases I should reverse it and use an if statement anywy.... but why not?


I'm not following. NOT NOT cancels itself out. Might as well say NOT NOT NOT NOT, or NOT NOT NOT NOT NOT NOT. It's all the same, and it all means "True" or "Yes" or "Equals" or whatever you're failing to negate. That's a basic rule of logic: you can add a double negative to any true proposition and not change its truth value at all.

As for "unless", that's actually the sort of thing that makes me homicidal about Ruby. Over and over again they make the decision that it is easier to learn a special piece of syntax than to use a basic construction that exists in almost every programming language.

Re: Why Indeed

2008-11-26 11:13 • by bitblit
beyond the mind
the answers wrought
why "not why?"
and not "why not?"
a "geez" illogical find
a carefully designed blind spot
the file sheds light
on oblivion's plot

Re: Why Indeed

2008-11-26 11:13 • by SomeCoder (unregistered)
231086 in reply to 231077
Satanicpuppy:
Qvasi:
Sometimes (like sombodys example above about !$inactive), it's more intuitive to have a "double negative" (I ain't not talking about no English double negatives, I mean logical: NOT NOT).

But mentally parsing a series of NOT's is hard, that's why I really loved the ruby statement 'unless' wich is essentially an 'if not' but it somehow makes it less taxing on the brain. What I don't like so much about it is that you can't say:
unless somecondition do

#something
else do
#something else
end

Of course when you need both cases I should reverse it and use an if statement anywy.... but why not?


I'm not following. NOT NOT cancels itself out. Might as well say NOT NOT NOT NOT, or NOT NOT NOT NOT NOT NOT. It's all the same, and it all means "True" or "Yes" or "Equals" or whatever you're failing to negate. That's a basic rule of logic: you can add a double negative to any true proposition and not change its truth value at all.

As for "unless", that's actually the sort of thing that makes me homicidal about Ruby. Over and over again they make the decision that it is easier to learn a special piece of syntax than to use a basic construction that exists in almost every programming language.


You missed the point. It's not like saying:

if (!!someCondition)

He's saying:

if (!inactive)

That's essentially a double negative to humans which is pretty easy to parse.

Also, if you can't understand unless... well it's not like the language forces you to use it. Just turn:

unless ($inactive)

into

if (!$inactive)

and voila.

Re: Why Indeed

2008-11-26 11:50 • by Zylon
I see Alex is still refusing to bury that horrible stillborn neologism of his. What was it, "develop me suction", or something dumb like that?

Re: Why Indeed

2008-11-26 12:04 • by dividius (unregistered)
231101 in reply to 231042
Synchronos:
Aah, yes, I see it!

The correct form would be: if isTrue(not contact_id <> 0) then


Insufficiently Flexible. How about:

if eqBoolean(not contact_id <> 0, TRUE)

?

Re: Why Indeed

2008-11-26 13:11 • by iMalc (unregistered)
Hrm, I've worked on contact-ID dialling and I don't not hate it!

Re: Why Indeed

2008-11-26 14:02 • by ThePants999
231131 in reply to 231097
Zylon:
I see Alex is still refusing to bury that horrible stillborn neologism of his. What was it, "develop me suction", or something dumb like that?

It's meant to be a combination of development, test, production - but it is truly awful, isn't it?

Re: Why Indeed

2008-11-26 15:59 • by Logic (unregistered)
231147 in reply to 231069
DaveK:
Jim:
That line is an artifact of using grep an misdirecting the output into a file by mistake
Why should it be a mistake? People often direct the output of grep to a file on purpose, like because they might want to refer to it later, or if they think there might be aa awful lot of output. These files are transient in nature and often named according to the passing whim of the programmer, or whatever's foremost in their mind at the time; hence they are often given names such as "wtf.txt", "crap.log", "fuckfuckfuck.txt", "aaaarrrrrrggghhhh.txt" or "iamgoingtoFUCKINGKILLMICROSOFT.txt". Presumably "why.txt" is shorthand for "whythefuckdoesittestthisvariableandicantevenfuckingfindanywhereitevergetssetoranysoddingreferencetoitatallFORCRYINGOUTLOUD!.txt"



Indeed. I find nothing surprising (save perhaps the filename). Even that can probably be explained (other than the .txt bit - although this bloke may not be a UNIX natural). A frustrated programmer debugging might use all sorts of names for temporary files (and this is, after all what this was intended to be, one would think) - "Why" would be quite a natural filename to use when you are getting frustrated that you can't find why your program is misbehaving and you grep for (quite probably also) contact_id to see whether it is being modified elsewhere.

Many people redirect output of grep to a file in case there is a lot - presumably person in question was seeing strange behaviour with the double negative, and was searching for the line to analyse it (and found it too, by the looks).

The only WTF I can see is that someone found it was absolutely baffled by iut, submitted it to TDWTF and had it posted.....

(Of course I may have missed something bleedingly obvious - like the double negative that that this poor chap missed, which clearly caused him {or her} all that grief....)

Re: Why Indeed

2008-11-26 16:03 • by rudraigh
231149 in reply to 231084
bitblit:
beyond the mind
the answers wrought
why "not why?"
and not "why not?"
a "geez" illogical find
a carefully designed blind spot
the file sheds light
on oblivion's plot


Nice.

Re: Why Indeed

2008-11-26 16:11 • by Petey (unregistered)
231151 in reply to 231147
Logic:
DaveK:
Jim:
That line is an artifact of using grep an misdirecting the output into a file by mistake
Why should it be a mistake? People often direct the output of grep to a file on purpose, like because they might want to refer to it later, or if they think there might be aa awful lot of output. These files are transient in nature and often named according to the passing whim of the programmer, or whatever's foremost in their mind at the time; hence they are often given names such as "wtf.txt", "crap.log", "fuckfuckfuck.txt", "aaaarrrrrrggghhhh.txt" or "iamgoingtoFUCKINGKILLMICROSOFT.txt". Presumably "why.txt" is shorthand for "whythefuckdoesittestthisvariableandicantevenfuckingfindanywhereitevergetssetoranysoddingreferencetoitatallFORCRYINGOUTLOUD!.txt"



Indeed. I find nothing surprising (save perhaps the filename). Even that can probably be explained (other than the .txt bit - although this bloke may not be a UNIX natural). A frustrated programmer debugging might use all sorts of names for temporary files (and this is, after all what this was intended to be, one would think) - "Why" would be quite a natural filename to use when you are getting frustrated that you can't find why your program is misbehaving and you grep for (quite probably also) contact_id to see whether it is being modified elsewhere.

Many people redirect output of grep to a file in case there is a lot - presumably person in question was seeing strange behaviour with the double negative, and was searching for the line to analyse it (and found it too, by the looks).

The only WTF I can see is that someone found it was absolutely baffled by iut, submitted it to TDWTF and had it posted.....

(Of course I may have missed something bleedingly obvious - like the double negative that that this poor chap missed, which clearly caused him {or her} all that grief....)


What's more, this file has highlighted the problem that presumably the submitter was looking for - the problem with contact_id can be found in the file
/cart/checkout.asp
at line 15....
I think the question 'why' has been quite successfully answered....

I have to agree, the WTF is more with the submitter (and some of the people above :P ) I would say....

Re: Why Indeed

2008-11-26 18:35 • by Or... (unregistered)
231168 in reply to 231030
Why (!(not not))...!

Re: Why Indeed

2008-11-26 18:51 • by poopdeville (unregistered)
231170 in reply to 231077
Satanicpuppy:
Qvasi:
Sometimes (like sombodys example above about !$inactive), it's more intuitive to have a "double negative" (I ain't not talking about no English double negatives, I mean logical: NOT NOT).

But mentally parsing a series of NOT's is hard, that's why I really loved the ruby statement 'unless' wich is essentially an 'if not' but it somehow makes it less taxing on the brain. What I don't like so much about it is that you can't say:
unless somecondition do

#something
else do
#something else
end

Of course when you need both cases I should reverse it and use an if statement anywy.... but why not?


I'm not following. NOT NOT cancels itself out. Might as well say NOT NOT NOT NOT, or NOT NOT NOT NOT NOT NOT. It's all the same, and it all means "True" or "Yes" or "Equals" or whatever you're failing to negate. That's a basic rule of logic: you can add a double negative to any true proposition and not change its truth value at all.



Careful. It is usually true that double negatives "cancel out", but not always. The Howard-Curry isomorphism theorem shows that a computer program can be identified with a "constructive" proof. Double negatives being equivalent to the no-negative version of an expression is NOT in general true for a constructive proof, and specific cases must be proven as such.

Back to slashdot with thee. ;-)

Re: Why Indeed

2008-11-26 19:14 • by 50% Opacity (unregistered)
"Well, uhh, I don’t know where he’s NOT. It wouldn’t be inaccurate to assume that I couldn’t exactly not say that it is or isn’t almost partially incorrect."

"So you do know where he is?"

"On the contrary. I possibly more or less not definitely rejected the idea in no way with any amount of uncertainty that I undeniably do or do not know where he shouldn’t probably be. If that indeed wasn’t where he isn’t. Even if he wasn’t where I knew he was…"

Re: Why Indeed

2008-11-27 04:58 • by A Ex-Tutor (unregistered)
231287 in reply to 231173
Ok, I know we should not make fun of students code, but I just have to share that line one of the students I tutored turned in:

if (not_done != false)


it actually took me a while to figure out what he tried to do.. then I took him aside and told him friendly to never ever do anything like this again.
« PrevPage 1 | Page 2Next »

Add Comment