- 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
Admin
72 null to mimic required current Java behaviour. 73 Null in case Sun changes naming conventions in future versions of Java. 73 NULL for when it's so really, really null that you need to shout about it. Also handy for JNI interfaces. 74 undef for Perl compatibility. 75 Nil for compatibility with most other dynamic languages. 76 IsNotIsNotNyahNyahNyah for the special Playground Edition.
Of course, you'd need to wrap all of these up in a try/catch/throw NullReferenceException, but that's a small price to pay for completeness.
Admin
That's more like a Magic 20-ball list
Admin
This also eases regionalization, as in: 23 Ja 24 Nein 25 Oui ...
Admin
Initializing a list to hold all possible 32-bit float values (IEEE 754) would take up 16 gigabytes of memory, just for the floats themselves (so at least double it for the pointers and other stuff in the list structure), and should only take a few seconds to create, on any relatively modern machine that has that much memory.
Admin
Aw man, I kept thinking the title should be "OurBoolean, OurSelves"
[/dating myself]
Admin
You need a girlfriend.
Admin
OurBoolean.getList().clear();
Admin
was getList() ever used?
Admin
No one has mentioned the very first WTF: obtaining a boolean value from a database as a String. This is almost certainly the fault of the database designer, who's probably one of those DBAs who thinks he/she should implement as much application logic in the database as possible, so instead of storing booleans as the smallest allowed integer types (I think Sybase has a 1-bit data type), he/she used varchar(5), which cannot be retrieved using ResultSet.getBoolean.
Admin
You know, a line HAS to be drawn SOMEWHERE, even in WTF code.
Admin
It's an 8-ball from billiards, but it has more than 8 answers: http://en.wikipedia.org/wiki/Magic_8-Ball
Admin
77 TheseAreNotTheDroidsYouAreLookingFor
Admin
The real WTF is they used VB.
Admin
No they didn't. There's no line numbers.
Admin
Seriously. I'm looking at the schema right now.
Admin
TRWTF is that he uses toUpperCase like its a field.
Admin
Here's on more:
kyllä Kyllä kYllä KYllä kyLlä KyLlä kYLlä KYLlä kylLä KylLä kYlLä KYlLä kyLLä KyLLä kYLLä KYLLä kyllÄ KyllÄ kYllÄ KYllÄ kyLlÄ KyLlÄ kYLlÄ KYLlÄ kylLÄ KylLÄ kYlLÄ KYlLÄ kyLLÄ KyLLÄ kYLLÄ KYLLÄ ei Ei eI EI
Admin
Just wait 'til that guy does something with real numbers...
Shudders too
Admin
I find the people who most loudly assert TRUE are usually the ones returning FALSE.
Admin
Admin
You guys forgot: Splunge!
Admin
This would have been a lot easier using frames...
Just sayin'
Admin
Admin
Obviosuly preparing for future i8n support. :) You never know how long words some language may have for YES and NO. Also not trusting the database to contain the right case of YES and NO is nice.
Admin
Not only there's nothing wrong with it, it is the only sensible thing to do if you want your system to be maintainable and expandable, which are two of the promises made by OO - if you use it correctly, that is ;o)
Speaking of correct use - there are two more major WTFs:
Both issues can easily be overcome (the fact aside that this improved implementation would still be stupid boolean-wise!! ;o):
This does lazy instantiation implicitely in a thread-safe manner as soon as the class is loaded, coded in the static initializer block which is called exactly once at class loading time. This also allows to declare the reference variable "list" as final (not that this is really necessary, it's private after all, just as a hint to others reading our code ;o)
The call to the static initializer happens when the class is used for the first time, in this case if someone called OurBoolean.getList(). Only using the constants OurBoolean.FALSE or OurBoolean.TRUE respectively will however not trigger the lazy instantiation.
Finally (to make it a real singleton), we add the "final" keyword to the class declaration and add a private default constructor - the class only has static members, so there's no point in it being instantiable and inheritable.
This is the best idiom for implementing the singleton pattern in Java. It is also possible to declare getList() as synchronized, but that imposes a runtime penalty on each call to getList(), not only the first one.
The call to Collections.unmodifiableList() solves the second issue - the reference returned by getList() will now deny any attempts to add/remove elements or clear the whole list by throwing an exception.
Admin
What about 1 and 0?
Or doesn't SQL accept that.
Admin
They probably did this as their DBA decided to store booleans in the database as varchars (hint: the db.utils package?). Many databases don't or didn't support booleans. While I would've gone with a bit instead of a varchar, it's not a huge WTF.
Admin
This is rather impressive, but you need to check on the class design critiques above. There are many excellent reasons to make this class inheritable (such as NotQuiteOurBoolean, OurI18NBoolean, and my own contributions, OurPossiblyNullBoolean and YoMommaBoolean). Clearly, OurBoolean should reside in a much-used and much-loved library. Making bits of it final would defeat the purpose.
In fact, I don't think it should be a class at all. I think it should be an interface.
We need to work on this.
Admin
I hate Java. Makes me upchuck a little every time I see it. Bleh! As for ourBoolean, I guess someone learned to do things the long hard stupid way. Java teachers are predominantly useless fecks, too.
Admin
Why? Oh god, why? Us C programmers survive with 0's for false and (void*)NULL and everything else for true. Makes purfect sense. And back in the old day when people used assembly we just used the zero flag to determine the truethness...
Admin
Don't forget the "t" and "f"!
Admin
Reminds me of the WTF where the code can go to 14.
Admin
Why does the internal database representation depend on how the GUI is implemented?
Please tell us what company you work for and who is your client....
That way, the rest of us can be sure to turn down positions at your company and your client's.
Admin
Why does the internal database representation depend on how the GUI is implemented?
Please tell us what company you work for and who is your client....
That way, the rest of us can be sure to turn down positions at your company and your client's.
Admin
Yeah yeah allright, my mistake. I just meant to change the parameters not the uppercase. if 'A' can be null and B can never be null, don't write (A !=null && A.equals(B)) but write (B.equals(A)) just to avoid another not-null-check...
The toUpperCase method was not the point...
Admin
Haha, the "file not found" jokes just don't get old. Come one, I thought this site was about smart but dubious hacks. This is just boring.
Admin
you forgot 1 and 0
Admin
lol @filenotfound
Admin
And this, ladies and gentlemen, is why some projects are never completed... on time, on budget, or at all.
"Something that is complex and sophisticated is not always the best and reliable. What is simple is better."
Admin
Fantastic! That's the kind of statement I started programming for ;^)
Mind you, this whole thing is only one step on from soem of the people I did my MSc with, who used to write code like "if (var == true)" and (even better) "if (var != true)". I got bored of pointing out the futility of this eventually...
Admin
Got one.
Admin
Admin
REAL WTF! There is NO optimisation at all, because in Java equal strings will return very SAME object, so no need caching.
Things going worse, because there are no protection against multithread access, so in turn it is possible to get TWO list objects (But regarding to what I say above, it is not relevant)
Captcha: uxor (wtf?)