Comment On A False Detector

Today I've decided to abstain from my normal introduction so that we may focus our full attention on this function that Mikhail K came across in a production system ... [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: A False Detector

2005-07-28 14:21 • by Mung Kee
so there is no "true" or "false" in M$ land?

Re: A False Detector

2005-07-28 14:22 • by Ytram
39327 in reply to 39326
That's not C#, I'm pretty sure it's java.

Re: A False Detector

2005-07-28 14:23 • by bugsRus
That's not just a WFT, it's also an OMG.  How do these people idiots get jobs?





Re: A False Detector

2005-07-28 14:23 • by Mung Kee
39329 in reply to 39327
Ytram:
That's not C#, I'm pretty sure it's java.




You are correct sir

Re: A False Detector

2005-07-28 14:23 • by Patrick
No way.  That can't be real.



No way.

Re: A False Detector

2005-07-28 14:24 • by rlewallen
Ok, somebody's just making this shit up now.  No way does that really exist in a production system somewhere.

Re: A False Detector

2005-07-28 14:24 • by Sean Connery
39332 in reply to 39330
Anonymous:
No way.  That can't be real.



No way.


Even if its real, it must be a joke. Trying to get into the daily wtf.

Re: A False Detector

2005-07-28 14:27 • by OMG
If a million monkeys got a million programming jobs, the first one to log in would write this.

Re: A False Detector

2005-07-28 14:27 • by jvm
39335 in reply to 39332
How do these people idiots get jobs?

I bet he's fat.

Re: A False Detector

2005-07-28 14:30 • by Matt
39338 in reply to 39330
That kind of idiocy just can't be explained. HOW HARD IS THIS:

boolObj.booleanValue();

Re: A False Detector

2005-07-28 14:31 • by El Duderino
SHENANIGANS!

Re: A False Detector

2005-07-28 14:34 • by Mung Kee
39340 in reply to 39335
Pat, I'd like to buy a not operator ("!")

Re: A False Detector

2005-07-28 14:34 • by Maurits
ROFLMAO



Not only is it ugly, it's WRONG!



checkFalse(true) is: true

checkFalse(false) is: false



Transcription error?

Re: A False Detector

2005-07-28 14:36 • by Daniel T
39342 in reply to 39332
Anonymous:
Anonymous:
No way.  That can't be real.



No way.


Even if its real, it must be a joke. Trying to get into the daily wtf.




The ONLY way this is real is that someone used some sort of code generator that somehow spit out this monstrosity.



There was a WTF a few weeks ago with something almost as bad with Integer/int.

Re: A False Detector

2005-07-28 14:36 • by El Duderino
39343 in reply to 39339

The WTF is that if I saw a method called CheckFalse() I would expect it to return TRUE given a FALSE input.  This idiot broke the semantic logic!

Re: A False Detector

2005-07-28 14:37 • by curtisk
39344 in reply to 39341
Maurits:
ROFLMAO



Not only is it ugly, it's WRONG!



checkFalse(true) is: true

checkFalse(false) is: false



Transcription error?




Just noticed that myself....LOL, and yeah its definitely not C# they use "bool" instead of "Boolean"

Re: A False Detector

2005-07-28 14:37 • by richleick
Ok, in no way am I trying to justify this, but the one thing that comes
to mind is that this was written for casting and/or type
compliance.  You see, Java, in its attempt to be OO compliant has
an int data type and Integer data type.  The Integer is an actual
class that has all sorts of functions.  Including something like
Integer.intValue().  So this was probably written because they
needed to use the bool type instead of the Boolean type.  Maybe
they were using a 3rd party module or something.



Then again, maybe this is just plain crap.

Re: A False Detector

2005-07-28 14:37 • by loneprogrammer
This is worthless.  It doesn't handle Boolean.MAYBE objects!

Re: A False Detector

2005-07-28 14:38 • by Jake Heidt

OH....


MY....


GOD.


 


[:'(][:'(][:'(][:'(]

Re: A False Detector

2005-07-28 14:38 • by Robin Lavallée
39348 in reply to 39341
Why not just rename the function to "identity". ?



Re: A False Detector

2005-07-28 14:38 • by bugsRus
39349 in reply to 39327
Ytram:
That's not C#, I'm pretty sure it's java.




You are correct!  It's Java.  And this developer moron abused is so many ways, it makes my head hurt.

Re: A False Detector

2005-07-28 14:43 • by bugsRus
39350 in reply to 39345
richleick:
Ok, in no way am I trying to justify this, but the one thing that comes
to mind is that this was written for casting and/or type
compliance.  You see, Java, in its attempt to be OO compliant has
an int data type and Integer data type.  The Integer is an actual
class that has all sorts of functions.  Including something like
Integer.intValue().  So this was probably written because they
needed to use the bool type instead of the Boolean type.  Maybe
they were using a 3rd party module or something.




Okay, I've been doing java for a while now, and I still have not come
across the bool type. Could you please tell all of us what that is?





Java does in fact have a primitive boolean, and the wrapper Boolean, just like int and Integer.



richleick:


Then again, maybe this is just plain crap.




Yes, I think you hit the nail on the head.



Re: A False Detector

2005-07-28 14:51 • by travisowens

While I will admit this code is slightly wierd, I will defend the reasoning behind it. I can tell you now this was done purely for human legibility of code.  While I haven't done something this simple of a check, I've often created methods soley for the reason of more readable code.


But I have created super simple methods such as IsNullOrEmpty() because calling this like   if (IsNullOrEmpty(x))  is much more readable than   if (x == null or x == "")


But I think somebody took this concept way to far because he already has a boolean to check against.


I try to make my code as english readable as possibly, call it dumbing it down, but even a non coder can understand the basics of my OOP code.

Re: A False Detector

2005-07-28 14:56 • by jb
and when bool is null, you get a nice NullPointerException

Re: A False Detector

2005-07-28 14:57 • by El Duderino
39353 in reply to 39345

richleick:
Ok, in no way am I trying to justify this, but the one thing that comes to mind is that this was written for casting and/or type compliance.  You see, Java, in its attempt to be OO compliant has an int data type and Integer data type.  The Integer is an actual class that has all sorts of functions.  Including something like Integer.intValue().  So this was probably written because they needed to use the bool type instead of the Boolean type.  Maybe they were using a 3rd party module or something.


Then again, maybe this is just plain crap.


My Java knowledge is limited but even I can tell that the bool in the code is the parameter name; all of the other references are to Boolean.  So I think your alternate hypothesis must be this.checkFalse(TRUE).

Re: A False Detector

2005-07-28 15:03 • by Ytram
39355 in reply to 39353
C'mon guys, you all know what richleickis referring to.  He said bool, but he really meant boolean
As in the primitive data type.  Don't let typos/semantics/etc. get
in the way of what really matters:  How crappy the code is in this
WTF.

Re: A False Detector

2005-07-28 15:06 • by richleick
39356 in reply to 39355
Ytram:
C'mon guys, you all know what richleickis referring to.  He said bool, but he really meant boolean
As in the primitive data type.  Don't let typos/semantics/etc. get
in the way of what really matters:  How crappy the code is in this
WTF.




Thanks, my cent a mints exactly

Re: A False Detector

2005-07-28 15:06 • by SkittlesAreYum
39357 in reply to 39345
richleick:
Ok, in no way am I trying to justify this, but the one thing that comes
to mind is that this was written for casting and/or type
compliance.  You see, Java, in its attempt to be OO compliant has
an int data type and Integer data type.  The Integer is an actual
class that has all sorts of functions.  Including something like
Integer.intValue().  So this was probably written because they
needed to use the bool type instead of the Boolean type.  Maybe
they were using a 3rd party module or something.



Then again, maybe this is just plain crap.




There is no bool type.  There's boolean (primitive) and Boolean
(wrapper).  If he wants the primitive value, all he has to do is
call booleanValue() on the wrapper.



So, in relation to the code posted, instead of that function they would
just have to do bool.booleanValue(), and it would return the exact same
thing as their function.

Re: A False Detector

2005-07-28 15:08 • by Mung Kee
39358 in reply to 39351
travisowens:
I try to make my code as english readable as
possibly, call it dumbing it down, but even a non coder can understand
the basics of my OOP code.




How readable is this to the average simian, assuming there is an "if" somewhere calling this?

if(!bool.booleanValue()){



}



I guess with yuor approach, the CFO and the VP of Marketing will know exactly what's going on in the code.





Re: A False Detector

2005-07-28 15:10 • by Ytram
39359 in reply to 39357
Anonymous:
richleick:
Ok, in no way am I trying to justify this, but the one thing that comes
to mind is that this was written for casting and/or type
compliance.  You see, Java, in its attempt to be OO compliant has
an int data type and Integer data type.  The Integer is an actual
class that has all sorts of functions.  Including something like
Integer.intValue().  So this was probably written because they
needed to use the bool type instead of the Boolean type.  Maybe
they were using a 3rd party module or something.



Then again, maybe this is just plain crap.




There is no bool type.  There's boolean (primitive) and Boolean
(wrapper).  If he wants the primitive value, all he has to do is
call booleanValue() on the wrapper.



So, in relation to the code posted, instead of that function they would
just have to do bool.booleanValue(), and it would return the exact same
thing as their function.




The biggest WTF today is all the people wanting to fight about wording.

Re: A False Detector

2005-07-28 15:18 • by Alex Papadimoulis
39360 in reply to 39341

Maurits:

Transcription error?


Today's code is actually verbatim. I saw no point in anonymozing this ;-)

Re: A False Detector

2005-07-28 15:25 • by John Smallberries
39361 in reply to 39341
Maurits:
ROFLMAO




Not only is it ugly, it's WRONG!




checkFalse(true) is: true


checkFalse(false) is: false




Transcription error?



How do you know it's wrong? If the function was named isFalse() instead of checkFalse(), then it would sure seem wrong.

As it is, the semantics of check aren't clear (another WTF).




The expanding wonder of the world

2005-07-28 15:26 • by Kazrael
39362 in reply to 39359
how code looks to a real coder:

if (booleanValue){

    //complete task

}



how code looks to newbs:



if (booleanValue == true) {

    //complete task

}



how code looks to the moron/crack addict who wrote the WTF code



function boolean figureBoolean( boolean bool) {

    if( (booleanValue == true) && true) {

        return true;

    else if( (booleanValue == false) && !false) {

        return false;

    } else

        return figureBoolean( (rand() % 2) == 1);  

}

    if (figureBoolean (myBoolValue == true)) {

      //complete task

    }



Re: A False Detector

2005-07-28 15:52 • by DelawareBoy
I just have Samir's (from Officespace) voice going through my head: "You are a very bad person..."

Can't say it better myself.

Re: A False Detector

2005-07-28 16:04 • by dhromed
39366 in reply to 39351
travisowens:

While I will admit this code is slightly
wierd, I will defend the reasoning behind it. I can tell you now this
was done purely for human legibility of code.  While I haven't done
something this simple of a check, I've often created methods soley for
the reason of more readable code.



But I have created super simple methods such as IsNullOrEmpty() because calling this like   if (IsNullOrEmpty(x))  is much more readable than   if (x == null or x == "")



But I think somebody took this concept way to far because he already has a boolean to check against.



I try to make my code as english readable as possibly, call it
dumbing it down, but even a non coder can understand the basics of my
OOP code.








Barely, sir, barely.


Certainly not worth the extra cycles for the function call and
execution (no matter how light), as well as the dependency on the
library that contains these check-functions.





this:





if (somethingsomething)






...reads just fine to anyone with a 10-minute crash course in the basics of any language.





I'm curious, why do you cater to non-coders? Why are non-coders looking at your code?





PS.


In your defense, we have an isEmpty() function in our library, to check
for "", 0, null and false, because you're right that putting those four
compares in the if() doesn't help readability.





I never use it.

Re: A False Detector

2005-07-28 16:05 • by Code6
39367 in reply to 39365
Wow, I was sure I'd seen some dumb stuff, but that... What kind of code
do these type of morons come up with when they are actually faced with
a "complex" problem to solve?



What I want to see is how this particular asshat handles enums! If it
took that much code to figure out a true/false statement, I can't wait
to see what else this guy could come up with. And an enum is trivially
simple. I want to see this cat go after some threading or something
that is seriously above his mental capacity. lol.



Things like this just remind me that there really are some people I could piss on mentally.

Re: A False Detector

2005-07-28 16:30 • by johnl
39368 in reply to 39367

this is bad , but not as bad as the


 #define INTEGER_VALUE_ONE 1


one that there was a while back.

Re: A False Detector

2005-07-28 16:50 • by evnafets
39369 in reply to 39346

loneprogrammer:
This is worthless.  It doesn't handle Boolean.MAYBE objects!


No, the whole point of this code seems to be to avoid that pitfall.  Note the catch-all else.  If it is Boolean.FALSE, the method returns Boolean.FALSE.booleanValue().  For all other values:  Boolean.MAYBE, Boolean.SOMETIMES, Boolean.IF_THE_WIND_IS_IN_THE_WEST the function returns Boolean.TRUE.


Obviously this is a programmer who has to work with people of produce Boolean.MAYBE values, and he wants to put a stop to it
This code does that brilliantly  [8-)] [:S] [:|] [:'(]

Re: A False Detector

2005-07-28 16:53 • by WTFer
I must admit I did once:



if(boolValue == true){

    ...

}



during my college years. Yes, I am ashamed. Don't look at me, I am hedious. (But this guy is much worse).

Re: A False Detector

2005-07-28 16:57 • by petvirus
I must say, i found this code, its real, it was in a system i recently started working on. There was other WTFs in the system, but nothing as bad as this.

There was also some really REALLY big chunks of code to do what parseInt() does and such.

Re: A False Detector

2005-07-28 17:02 • by Hank Miller
It isn't often that code makes be burst out laughing, but this managed to do that.





Forget the OMG, this code jsut doesn't have the lenght for that. (though it comes close)





It isn't a case of paid by LOC, though that is perhaps the most logical explination.





It isn't a WTF, If it was I wouldn't comprehend the whole thing in
seconds like I could for this.   Most of the code seen here
takes me a little time to comprehend.





No, this is just a burst out laughing right in my cube function.




At least it is readable.  Not as readable is if(foo), but it is
readable.  (though as other noted it returns the wrong value)

Re: A False Detector

2005-07-28 17:03 • by Mung Kee
39373 in reply to 39371
petvirus:
There was also some really REALLY big chunks of code to do what parseInt() does and such.




Now that would be a gem

Re: A False Detector

2005-07-28 17:13 • by Smokey

C'mon anybody could guess that this just makes the following code all that much easier!

new FalseChecker().checkFalse( new Boolean( Boolean.FALSE.booleanValue())) ? true : false;

Geez, use some creativity!


[|-)]

Re: A False Detector

2005-07-28 17:28 • by raolin
39376 in reply to 39370
While that is inelegant, there have been times when I was maintaining
code that had very, *very* poorly named variables and doing the
explicit (boolValue == true) was the only way to make the code the
least bit intuitive. 

Re: A False Detector

2005-07-28 17:30 • by diGriz
*rotfl* That one's really funny.

Re: A False Detector

2005-07-28 17:47 • by rsynnott
39378 in reply to 39335
Anonymous:
How do these people idiots get jobs?

I bet he's fat.





Now, now. There are stupid thin people too. Stop it now, before NAAFA gets you.



travisowens:

While I will admit this code is slightly
wierd, I will defend the reasoning behind it. I can tell you now this
was done purely for human legibility of code. 




To hinder it?




Re: A False Detector

2005-07-28 18:56 • by phelyan
I've just lost my breakfast...

Re: A False Detector

2005-07-28 19:14 • by sabatick
39381 in reply to 39348
Anonymous:
Why not just rename the function to "identity". ?


Because it would be a lot of work to handle all kinds of objects which you want to work identity on.

Just consider how hard it would be to write idenity for objects which refuse to be cloned.

Not to mention the problems due to the lack of multimethods in Java.

I thinks that guy did a good job at pointing out how much fun programming is.





Re: A False Detector

2005-07-28 19:39 • by Maurits
39382 in reply to 39381
Anonymous:
Anonymous:
Why not just rename the function to "identity". ?


Because it would be a lot of work to handle all kinds of objects which you want to work identity on.




Whatchoo talkin' bout, Willis?



public Object identity(Object obj)

{   return obj;

}



If you want to handle Java's native types too, go ahead... or just
require the caller Boolean-ify his booleans, etc.  I forget how
many non-Object native types there are in Java, but it's certainly less
than ten.

Re: A False Detector

2005-07-28 20:00 • by foxyshadis
39383 in reply to 39376
Anonymous:
While that is inelegant, there have been times when I was maintaining
code that had very, *very* poorly named variables and doing the
explicit (boolValue == true) was the only way to make the code the
least bit intuitive. 




if(fish)

  throw NoFish;

elseif (recurse == pangalacticgargleblaster)

  throw BlowYerStack;

else

  assert("Hi.");

« PrevPage 1 | Page 2 | Page 3Next »

Add Comment