- 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
Admin
It's called "yellow".
Admin
Ahhh, so the Boolean Object does not default to "false" like the primitive...Why would one use the object, instead of the primitive?
Admin
Dude! This is so Zen-like that there is nothing that can be said about the code itself.
Admin
Several reasons. Primitive wrappers are immutable, java collections cannot store primitives*, and wrappers extend Object, so can be treated and passed around as such. Also, the wrapper classes provide methods to parse Strings into their respective types.
<FONT size=2>*the autoboxing of the new collections silently wraps the primitive and then adds it to the collection.</FONT>
Admin
Bugger... that bottom bit was supposed to be smaller, not larger... WTF richtext fields...
Admin
I'm.... speechless.
Admin
That's pretty funny ... stupid ... but funny.
Admin
One more flaw that no one has mentioned yet:
Yeah, the only reason someone would use the Boolean object instead of a primative boolean in java, is it you want the object to be nullable. This guy's checkFalse function is that it will throw a NPE if the argument is null.
Admin
I think Java encourages bad programming practices. I'm finding it harder and harder to hire qualified folks who were raised on it.
Admin
I don't think Java encourages bad practices, I think the problem is that it is an easy language to learn, it's relatively young, and few people are 'raised on it' yet. It's more forgiving than other languages, making it easier to learn and easier to get away with bad code. It's a two edged sword, but the fact that it doesn't discourage bad practices doesn't mean it encourages it. Managers who can't (or can't be bothered to) manage their staff encourage bad practice.
I've seen some bad developers in my time and 2/3rds of them were not bad at Java, or bad at programming (sure, I've seen some howlers as well), but had come fresh from university or were self-taught and had no commercial experience. Where I see developers struggle is not the code, it's understanding what the code is supposed to do. Too many programmers are smug gits that look down on their customers and don't give a flying about the finished product and its uses.
Admin
Somewhere, someone, assuming this isnt a sham...was paid to write this..will someone tell me: how well must one know Java to get a job programming Java?
Admin
1 year experience with java will get you a job worth 23,000 pounds/year in London, UK. For reference, that's about the same a Head Chef in a restaurant will get.
Admin
Ok, boys and girls, I have another way they could have implemented this:
static Set trueSet;
static Set falseSet;
static {
Set s = new HashSet(1);
s.add(Boolean.TRUE);
trueSet = Collections.unmodifiableSet(s);
s = new HashSet(1);
s.add(Boolean.FALSE);
falseSet = Collections.unmodifiableSet(s);
}
public boolean checkFalse(Boolean bool) {
if(trueSet.contains(bool)) return Boolean.TRUE.booleanValue();
if(falseSet.contains(bool)) return Boolean.FALSE.booleanValue();
// otherwise the universe is collapsing!
throw new IllegalStateException("The universe is collapsing!");
}
What do you think?
Admin
1 year experience in Java, academically or professionally?
Admin
That's just a load of bool!
Admin
Professionally. Hard experience counts a lot more in the UK. 3-4 years commercial java experience gets you a decent job, even if you have no degree. Take it from an old web monkey like myself.
Admin
mm maybe he thought that Boolean would be expanded with 'OK', 'Cancel' and 'Abort', 'Rety', 'Fail' [:D]
but still that wouldn't explain the return [^o)].
Admin
You could check out www.lambda-the-ultimate.org. Although it isn't about
well-written code per se, there are often discussions about how to express
something in a clean manner.
The site is good to read even if one isn't interested specifically in
non mainstream languages, just for the perspective.
Admin
The problem is that if (boolValue == true) is bad (at least in C and C++). The reason for this is that in C++, 0 is false and everything else is true. Tecnically, true is "defined" as 1, but 1 isn't the only true value (pun intended).
Certain C library function (often used from C++ as well) return 0 on failure and non zero on success. Therefore, you never check if (x == true), but rather if (x) or if (x != 0) if you absolutely HAVE to write it out.
Admin
The Daily WTF reminds me how comedic code can be.
Admin
I think that is a wonderful demonstration of encapsulation - you never know when Boolean will have a third or fourth value and hiding it here allows rest of the code to work without change. [;)]
Admin
Wink wink ...
No, you see, this is just plain crap, your pathetic apologies notwithstanding. As has already been pointed out, this function is bool.booleanValue() rewritten in a thoroughly WTFish way, and even the name is a WTF, since this function does not check whether its parameter is false. May I point out that this method should have been
static
, too?I'm always amazed at the amount of nonsense some bleeding-heart coders will spout to justify the most obvious and inexcusable WTFs. Why can't you just acknowledge that there are idiots who write highly idiotic code for no reason whatsoever?
Admin
That's idiotic! Whomever in the universe that cannot read if (x == null or x == "") does not merit even looking at the code, much less mantain it.
What, are we writing code for morons now? Code should be legible, yes -- but legible to PROGRAMMERS. There should be some sort of skill or education requirements regarding the platform for anybody to work on it.-dZ.
Admin
Ha ha ha! Funny! You misspelled VisualBasic...!
dZ.
Admin
you might bump into a null value, dude !
Not that this WTF is any null-safer, though :^)
Admin
s/Java/$random_programming_language/g
Admin
i think it's just a joke. No one with a little bit experience in IT development could write such a function. And somebody who had one year XP in maths or electronic know what booleans are. So i don't think this post is really serious.
Admin
Well, perhaps by writing the function you could at least encapsulate the fact that it should be
(x == null || "".equals(x)) in Java.
Admin
(x == null || "".equals(x)) in Java.
Admin
I agree with an eariler poster... this isn't a WTF it is an OMG!!!!
As in Oh My God, it burns, it burns lol!
Admin
You've already acknowledged your mistake, but I would just like to rehash it. Mainly because you said "M$" in your first post that you rushed out in your hurry to bash Microsoft. Why doesn't "$un" get bashed now? How come I never see "The real WTF is that someone used $un's programming language!"?
P.S. I can't stand it when people type "M$", "New York Yankee$", etc.
Admin
For the record - Boolean is equivalent to bool in C#, just as Single is equivalent to float, since they are the canonical .NET class names (also valid in VB.NET, etc.).
Admin
Yeah, I managed to restrain myself earlier, but...
Do you guys who write M$ or Micro$oft still think you're witty? It's been done, pick up something else. All other arguments against Microsoft aside, come up with some original material.
Admin
I'm still in pain when I consider Visceral Baysuck, where a glance at the documentation shows an IsEmpty(), IsMissing(), and IsNull(), and then the Nz() function in Access, all of which provide, shall we say, "entertaining" semantics as you WTF your way through an task.
All I can say, man, is: pray for JavaScript.
Admin
Last I was interested in a Java position you needed at least 5 years of Java. This was in 1997 , so you would have to be a Sun employee to have a shot at that. (Java 1.0 was announced in 1995)
Last time I was looking for a job, were no Java only jobs, only 10 years Java, 5 years .Net. This was in 2003.
Of course you know what this means: the only people with Java or .Net jobs are people who can lie with a straight face and convince the PHB that they are telling the truth.
Admin
Here's the best bit,
Admin
There should be, yes, but there often isn't. Just last week one of my coworkers, who has plenty of experience working with our company's data but absolutely no programming experience whatsoever, was given the task of maintaining a VB .Net application. He's never, ever, touched anything resembling VB, VB .NET or any other programming language for that matter. My mind, it boggles!
Admin
What kills me is, this clown actually calls Boolean.booleanValue() in this crap method. He obviously knows it exists. If he called it in the first god damn place he wouldn't be the punchline right now.
Admin
How about Serialization? Also, certain forms of RMI require that you pass Objects and not primitives.
Admin
While I fully realize that it was/is a derogatory term for Microsoft, in this case, I assure you, it was merely shorthand.
Admin
I think the real WTF here is that there are 90 posts and nobody's recommended JavaScript or XML.
Admin
Ok, the REAL real WTF is that I actually searched the page for JavaScript and XML before making my post, and it didn't find either term.
Admin
I've gotten into the habit of using the System datatypes (System.Int32, System.Boolean) in my code. I was never sure why until I reviewed some old VB code and was reminded of the fabulous 16-bit Integer datatype.
There are no primitives in .NET, and I don't really miss them.
Admin
The language is Java. The developer is VB.
Admin
Ah, well in Java 1.5, there's autoboxing, so you can have something like:
@SuppressWarningsAutoboxing
....
Boolean test = new Boolean(true);
if(test)
.....
But really, I think having primative and object wrappers of the same data types is a huge WTF in java.
Admin
My experience is that VB, VB-esque languages, and Perl encourage bad practices. When Java was new, it had a whole philosophy (religion) built-up around it that were essentially bad practices. Perhaps that's what you are referring to. All of these stupid ideas are wholly discredited and largely abandonded but you still see some clueless people reading the old books and holding onto these ideas. There's a couple keynotes from Java One this year that talk about them that you can watch on the ServerSide. In particular Rod Johnson's "Why J2EE projects fail"
Admin
You could even just do this:
Boolean test = true;
if(test);
They should have just made primitives work the way that arrays work i.e. you could treat them as if they were Objects i.e. all the base Object class methods are defined for the primitive types but there's actually no Object involved. It would have saved everyone a lot of pain and suffering.
Admin
I don't see how this is a reason to use wrapper types. It doesn't give any extra modifcation protection.
Admin
No, its not that. CS programs have dumbed down. Eight years ago, I asked a professor, "When is this going to get hard," in reference to CS202 and CS203. The answer was that they had started making it intentionally easier so less people would drop out. The attrition rate from CS201 to CS203 was about 80%. Because its either Java or VB in most CS programs now, you're seeing a lot of people who would have been weeded out get degrees instead.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>