| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
Wow.... why does this happen so often?
|
|
That piece code is awesome!
Addendum (2010-07-14 09:58): I see Mark B. fixed his typo. Oh well. |
|
Maybe the friend doesn't like the exclamation mark in code? It's not easy to make this code shorter and not use an exclamation mark or question mark.
Reminds me of some code I saw once, which compared whether a certain integer was greater than 4 and less than 6. |
Re: Bulletproofed Boolean
2010-07-14 09:12
•
by
Matt Westwood
(unregistered)
|
if (value == false) { return true; } else { return false; } is shorter and doesn't include ! |
|
|
|
It pains me to think that people like this are out there coding right now. Probably adding a few helper methods like IsIntEqualToOne(int i) and IsStringEqualToFudge(string possiblyFudge).
|
|
Big bad boolean blunder built by belligerent baffoon.
Alliteration FTW |
|
At least
responsewas initialized. |
Re: Bulletproofed Boolean
2010-07-14 09:20
•
by
Skilldrick
(unregistered)
|
At least they're using descriptive names and parameters. Even better: int2(int x) {return x == 1;} |
|
public boolean isBooleanFalse(boolean value) {
boolean response = true; if (value == true) { response = false; } return response; } |
Reading is fundamental. |
Better still would be int int86(int x) {return x == 86;}, just for the horrific breakage when ported to DOS (which probably wouldn't be noticed immediately). |
Re: Bulletproofed Boolean
2010-07-14 09:33
•
by
Jukin
(unregistered)
|
|
|
we needed this, i stole it
|
|
Where is its counterpart, isBooleanTrue() ?!?
(Do Code-Reviews, and you would catch these omissions) Also, maybe somebody else there has already written isBooleanFalse(), and Brian's friend is reinventing the wheel. __ /hg |
|
Yes bulletproofed. As long as no-one passes a null of course.
|
Re: Bulletproofed Boolean
2010-07-14 09:39
•
by
Kim
(unregistered)
|
|
return value ^ true
is also shorter and doesn't contain ! |
|
I can imagine calls to that function might look something like this:
if isBooleanFalse(foo) == true {
|
Language comprehension is fundamental. To me, this code looks like Java. And Java distinguishes between primitive types and objects. boolean (lowercase) is a primitive type, where Boolean (uppercase) is an object. Objects can be null, primitives cannot. The parameter is declared boolean (the primitive type), therefore no null value possible there. |
Re: Bulletproofed Boolean
2010-07-14 09:49
•
by
Murf
(unregistered)
|
|
Obviously you're not an auto-boxer.
|
|
So - if that checks if a boolean is false, and returns a boolean - should i use this function to check if this function returns a false boolean?
Its a never ending coding loop!!!!!!!!!!!!! Dan www.3xg.co.uk |
Re: Bulletproofed Boolean
2010-07-14 09:50
•
by
charles
(unregistered)
|
|
|
I call bullshit! There's no friggin' *way* that someone smart enough to land a job could possibly be that fucked up.
|
|
Weak. We can do better.
|
Re: Bulletproofed Boolean
2010-07-14 09:53
•
by
tragomaskhalos
(unregistered)
|
You must be new to theDailyWTF my friend ! |
|
Obviously, the correct way of doing this would be to replace this function with a call to a web service that submits the boolean value to a MS SQL Server 2008 via stored procedure. The database would then return the correct value by means of a VarBinary(Max) value of a JPEG image of a scanned Polaroid photo of the word 'True' or 'False' written on different colored index cards photographed on a wooden table.
... or just not use the function in the first place. |
|
Defensive programming.
|
Re: Bulletproofed Boolean
2010-07-14 09:56
•
by
Burpy
(unregistered)
|
|
My senior developer coworker once asked me what I meant when I was refering to "boolean"... and I've already seen this kind of crap in his code (but as he's a C# developer he uses "bool" and never asked himself where does this 4 letters word comes from.)
|
My guess is that somebody is having an internal conflict between strongly-typed code and dynamic code, and they aren't smart enough to realize it. This code looks like an attempt to coerce anything to a boolean (poorly). It's funny to watch people go back and forth between "strong typing seems to help the compiler find my errors" and "strong typing requires me to do these annoying casts". The result is often pseudo dynamic code in a strong typed language. These people need to read an article in a programming journal at least once per decade. Or maybe even go to school. |
|
Did you by chance arrange it so that his genetic material no longer has any change of propagating through the gene pool?
|
Re: Bulletproofed Boolean
2010-07-14 10:00
•
by
monkeyPushButton
(unregistered)
|
That's right SuperJames, no one that stupid could get a job in development. And santa is watching you. And the toothfairy brought you that shiny new quarter. And scruffy is playing happily on a farm in the country. |
|
34th!!!!!!!!!11!!11!!!##!@##@ELEVEN
|
FTFY |
Re: Bulletproofed Boolean
2010-07-14 10:07
•
by
Anonymous
(unregistered)
|
Ahh, a newcomer. Welcome my friend, pull up a seat and prepare to lose any preconceptions you have of professionalism in the IT industry. |
|
return !(false & !!!x)
|
Re: Bulletproofed Boolean
2010-07-14 10:25
•
by
Antony Koch
(unregistered)
|
|
oops!
return !(false & !!!value) |
|
There you go, much better (and more complete):
public boolean isBooleanFalse(boolean value) { return !isBooleanTrue(value); } public boolean isBooleanTrue(boolean value) { return !isBooleanFalse(value); } |
|
The great thing about this is that it can be re-used to write isBooleanTrue...
Or, to keep the style consistent
|
Re: Bulletproofed Boolean
2010-07-14 10:32
•
by
Some Wonk
(unregistered)
|
No, no, no. The proper response is "Plz send teh codez" |
Re: Bulletproofed Boolean
2010-07-14 10:33
•
by
Professor Shitston Piss Phd.
(unregistered)
|
You forgot to use IoC
|
Re: Bulletproofed Boolean
2010-07-14 10:37
•
by
CaptainOblivious
|
public boolean isBooleanFalse(boolean value) {
Placing the code inline is even shorter, without ! or ?
|
And obviously you don't have the slightest clue how auto-boxing works. Well, auto unboxing since that's the only thing that would be affected here. In Java, even if you have a Boolean that needs to be auto unboxed into a boolean, it will happen in client code before the call to isBooleanFalse. There is positively NOTHING the library function could do, or should do, to change that. |
Re: Bulletproofed Boolean
2010-07-14 10:45
•
by
SR
(unregistered)
|
You're very lucky to work in such a competent team. |
Re: Bulletproofed Boolean
2010-07-14 10:51
•
by
Jason Y
(unregistered)
|
|
That depends on the language. If it requires initialization before use, then initializing it to a potentially wrong value is _bad_. If it does not require initializing, then initializing to a potentially right valid value is OK (though initializing to an invalid value like null is better, if you have the option).
Anyway, this example code isn't over-engineering, and isn't making anything more bullet-proof. It's just a very verbose way to implement the not operator. |
Re: Bulletproofed Boolean
2010-07-14 10:54
•
by
Jason Y
(unregistered)
|
|
Now _that_ is over-engineering!
captcha: jumentum - momentum initialized by a jump. |
Re: Bulletproofed Boolean
2010-07-14 11:18
•
by
neminem
(unregistered)
|
Well, I'm a newcomer too. I just started by reading the entirety of the back archives, so that I can reference all your memes: it's not enterprisey enough - where's the xml? See? |
Re: Bulletproofed Boolean
2010-07-14 11:23
•
by
Uncle Al
(unregistered)
|
This is actually quite common in embedded systems where exclamation points and question marks have been removed to produce a reduced character set. |
Re: Bulletproofed Boolean
2010-07-14 11:25
•
by
Anonymous
(unregistered)
|
Not bad but you need to add some embedded file systems, a bit of EVE Online, some Irish Girl and an honorable mention to Paula, Lyle and Rumen. Additionally, you must always remember that the true values of a boolean are TRUE, FALSE and FILE_NOT_FOUND. There, I think that just about covers it. |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |