|
|
|
| Non-WTF Job: Software Developer at Rustici Software (Franklin, Tennessee) |
| « Prev | Page 1 | Page 2 | Next » |
|
getList().at(0) is "TRUE" and getList().at(1) is "FALSE"? Yay...
|
|
Well that makes sense. The list allows one to iterate the values of OurBoolean and you never know how many boolean values there will be at compile-time.
|
|
It "optimizes for memory usage" by creating a 10-element list to hold boolean values...
|
|
Additional yay: all variables are strings! That makes it easier to do date processing and conditionals, because true==true confuses me, but "TRUE"=="TRUE" makes sense! yay.
TGIF! |
|
And imagine how extendable that code is!
Say, you want to port your code to a quantum computer. You just modify the OurBoolean class to return a float in range of [0-1] instead of strings, and you're home! |
What in the world makes you think that the default allocation of <10> is anywhere near enough to store a boolean value? 1 TRUE 2 "TRUE" 3 "True" 4 "true" 5 FALSE 6 "FALSE" 7 "False" 8 "false" 9 true 10 false 11 Boolean.TRUE 12 Boolean.FALSE 13 "Y" 14 "Yes" 15 "YES" 16 "y" 17 "yes" 18 "N" 19 "No" 20 "NO" 21 "n" 22 FileNotFound |
|
Everyone knows that "File not found" is 404 in those days. So there have to be at least 405 boolean values. That list starts to make sense to me.
|
Re: OurBoolean
2008-01-18 08:32
•
by
An apprentice
(unregistered)
|
Don't forget to initialise your list with all possible floats. |
|
And by calling it OurBoolean, he makes everyone responsible for this gem, not just him.
|
TEH WINNAR!!! |
|
By making it 'Our' boolean he manages to make it sound so much more romantic.
It's no longer YourBoolean, its OurBoolean. It's no longer YourCar, its OurCar. It's no longer YourCDs, its OurCDs. I wonder who will get which half of the Boolean when the relationship breaks down. Dibs on True! |
That might take while, but that shouldn;t be a problem for the quantum computer to do automatically. You'd first need to write a program for that tho, which will have toinclude OurBoolean, which will have to be initialized bij a quantum computer, which will need a program that... I think there might be a problem in that ;) |
|
Sure there is no problem. If you have a problem with some logical test just switch "TRUE" and "FALSE" in the list and you will have true at(1) and false at(0) changing the outcome. That is just great for testing!
You can even switch them while the program runs. Perfect for debugging and insane fun! |
|
I also like how getList() isn't thread safe and that they allocate a new String object on every comparison by using toUppercase with equals instead of just using equalsIgnoreCase.
|
IPPON! |
|
The real WTF is that he never used the ArrayList.
|
|
First of all, I don't understand why so many people whant to reinvent the wheel. Maybe they should get a lesson about basic java? Never heard of boolean or Boolean? Very funny, I guess they like doing some hard work over again :-)
And if they absolutely want to create a new Boolean type, they could have used (OurBoolean.TRUE.toUpperCase.equals(result)) instead of (result != null && result.toUpperCase.equals(OurBoolean.TRUE)) they wouldn't have to do a null-check because NullPointerExceptions will be avoid if you change the arguments in the equals method. |
|
While OurBoolean lacks a "FILE_NOT_FOUND", it looks like you can just add it later if you need it:
OurBoolean.getList().add("FILE NOT FOUND"); |
How do you dare to try to improve OurBoolean? It is OUR Boolean, not yours. Go write your own boolean! |
Re: OurBoolean
2008-01-18 09:33
•
by
Tom Hawtin
(unregistered)
|
java.util.Collections.reverse(OurBoolean.getList()); Problem solved. OurBoolean.getList().add("UNKNOWN"); |
You just fucked up the whole system. It depends on False being on the first/zeroth position. if(form.userWantsSpam().equals(OurBoolean.getList().at(0) || true){ } I love it. |
You got FILE_NOT_FOUND, I see, but you left out VERYTRUE and VERYFALSE. |
Gahh. And *I* forgot FAIRLYTRUE and FAIRLYFALSE. D'oh! |
Also UNKNOWN, MAYBE, SEG_FAULT, THE_FUTURE_IS_UNCLEAR, TRY_AGAIN_LATER and PAULA |
|
Yes we use this pattern a lot ourselves...
Its great if your client isnt quite sure how they want the values for TRUE and FALSE represented in the GUI....if they change their minds then its simple to just make a change to the code in one place... Over all this is a Brillant Pattern. |
Re: OurBoolean
2008-01-18 09:58
•
by
sdfsqdfqsdfsqdf
(unregistered)
|
That would mean that reqult.toUppercase() is always equals to result. |
|
Considering that this is used to check values from the database, there probably should be one for "NULL".
|
good, but you missed out 23. TrueFalse |
|
I would really like to know just what goes on in the mind of someone who is writing this. I just can't imagine how this could ever come into existence...
Of course, a lot of stuff on The Daily WTF fits that category... Eyes. Goggles. Nothing. |
|
Fixed:
What in the world makes you think that the default allocation of <10> is anywhere near enough to store a boolean value? 1 TRUE 2 "TRUE", "True", "true" 5 FALSE 6 "FALSE", "False", "false" 9 true 10 false 11 Boolean.TRUE 12 Boolean.FALSE 13 "Y", "Yes, "YES", "y", "yes" 18 "N", "No", "NO", "n", "no" 23 FileNotFound 24 Maybe, MAYBE, maybe 27 Possibly, POSSIBLY, possibly 30 SOMETIMES, Sometimes, sometimes 33 TrueFalse, truefalse, TRUEFALSE, TF, tf 38 VERYTRUE, VeryTrue, verytrue, VT, Vt, vt 44 VERYFALSE, VeryFalse, veryfalse, VF, Vf, vf 50 UNKNOWN, Unknown, unknown, U, u 55 TRYAGAINLATER,TryAgainLater,tryagainlater,TAL,Tal,tal 61 TheFutureIsUnclear 62 SegFault 63 Paula 64 WTF 65 NOTTRUE,NotTrue,nottrue,NT,Nt,nt 71 NOTFALSE,NotFalse,notfalse,NF,Nf,nf Thanks to all for corrections/ommissions |
Don't forget multiple language support: 23 "S" 24 "s" 25 "SI" 26 "Si" 27 "si" 28 "No[es]" 29 "NO[es]" 30 "no[es]" 31 "n[es]" 32 "Tu es loco, gringo." 33 "O" 34 "o" 35 "Oui" 36 "OUI" 37 "OUi" 38 "oui" 39 "n[fr]" 40 "NON" 41 "Non" 42 "non" 43 "Cochon americain" |
|
The real WTF is that they used List instead of ArrayList.
|
*shudders* |
Re: OurBoolean
2008-01-18 11:04
•
by
El Dudarino
(unregistered)
|
Hey wait... They DID use ArrayList!!! This code is just fine... |
There's nothing wrong with returning the interface to an object instead of the object itself. It's the one thing in that code that's NOT a wtf! |
You mean because such obviously idiotical programmers managed to get one thing right? |
You didn't allow for typos. |
|
I use to have a bunch of classmates that totally missed the point of having getters, like you show.
Objects were full of "getVector()" and "getList()". I started to argue with them about that, but quickly resigned... |
You left off "flase" |
if result = "true"; then (OurBoolean.TRUE.toUpperCase.equals(result)) becomes ("TRUE".equals("true")), your way fails. |
|
...just...wow...er...wow
Man this Initrode place is popping up all over the WTFs |
Excuse me ... unless you can provide some proof this is mine, I refuse all responsibility. This is copied directly from our code, with only the name of the company in the package changed to protect the innocent, not so innocent, and my job. It's actually used in one place to populate a drop down list for a web page (yes, where 0 = TRUE and 1 = FALSE) but in a dozen places to check if a result is true or false. Where the result is NULL, it's assumed to be FALSE, except where it's assumed to be TRUE. |
Re: OurBoolean
2008-01-18 11:33
•
by
BinaryPhalanx
(unregistered)
|
|
You left out a couple:
YEs yES yEs nO |
Not to mention that toUpperCase on OurBoolean.TRUE is, well, kinda silly? |
You also need values like "maybe', "perhaps", "unknown", "half-truth", "ask again later", 0, 1, "Zero", "one", "uno", "Zed" and so on to make this complete. |
|
I can't believe you left out the Magic 8-ball list:
● As I see it, yes ● Ask again later ● Better not tell you now ● Cannot predict now ● Concentrate and ask again ● Don't count on it ● It is certain ● It is decidedly so ● Most likely ● My reply is no ● My sources say no ● Outlook good ● Outlook not so good ● Reply hazy, try again ● Signs point to yes ● Very doubtful ● Without a doubt ● Yes ● Yes - definitely ● You may rely on it |
|
don't forget i18n - i bet we could get that list up to the hundreds in no time.
'oui', 'OUI', 'Oui', 'NON', 'non', 'Non', 'Nyet' ... |
Obviously you're not aware of the "time-memory" tradeoff. |
That's what? 2 languages? Here's two more: 44 "ТАК" 45 "Так" 46 "так" 47 "НІ" 48 "Ні" 49 "ні" 50 "НІЯКИЙ" 51 "Ніякий" 52 "ніякий" 53 "ДА" 54 "Да" 55 "да" 56 "НЕТ" 57 "Нет" 58 "нет" It looks like Hi and Het, but it is in fact Nie [like knee] and Nyet. Ніякий is left as an exercise for the reader. |
| « Prev | Page 1 | Page 2 | Next » |