• Vollhorst (unregistered)

    getList().at(0) is "TRUE" and getList().at(1) is "FALSE"? Yay...

  • krupa (unregistered)

    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.

  • (cs)

    It "optimizes for memory usage" by creating a 10-element list to hold boolean values...

  • (cs)

    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!

  • s. (unregistered)

    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!

  • (cs) in reply to ThePants999
    ThePants999:
    It "optimizes for memory usage" by creating a 10-element list to hold boolean values...
    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

  • Vollhorst (unregistered)

    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.

  • An apprentice (unregistered) in reply to s.
    s.:
    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!

    Don't forget to initialise your list with all possible floats.

  • (cs)

    OurBoolean > YourBoolean

  • (cs)

    And by calling it OurBoolean, he makes everyone responsible for this gem, not just him.

  • (cs) in reply to Vollhorst
    Vollhorst:
    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.
    TEH WINNAR!!!
  • (cs)

    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!

  • StarLite (unregistered) in reply to An apprentice
    An apprentice:
    s.:
    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!

    Don't forget to initialise your list with all possible floats.

    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 ;)

  • Vollhorst (unregistered) in reply to StarLite

    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!

  • Someone (unregistered)

    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.

  • sweavo (unregistered) in reply to snoofle
    snoofle:
    What in the world makes you think that the default allocation of <10> is anywhere near enough to store a boolean value?

    IPPON!

  • MA (unregistered)

    The real WTF is that he never used the ArrayList.

  • SoulReaver (unregistered)

    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.

  • JL (unregistered)

    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");

  • Vollhorst (unregistered) in reply to SoulReaver
    SoulReaver:
    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.

    How do you dare to try to improve OurBoolean? It is OUR Boolean, not yours. Go write your own boolean!

  • Tom Hawtin (unregistered) in reply to Vollhorst
    Vollhorst:
    getList().at(0) is "TRUE" and getList().at(1) is "FALSE"? Yay...

    java.util.Collections.reverse(OurBoolean.getList());

    Problem solved.

    OurBoolean.getList().add("UNKNOWN");

  • Vollhorst (unregistered) in reply to Tom Hawtin
    Tom Hawtin:
    Vollhorst:
    getList().at(0) is "TRUE" and getList().at(1) is "FALSE"? Yay...

    java.util.Collections.reverse(OurBoolean.getList());

    Problem solved.

    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.

  • (cs) in reply to snoofle
    snoofle:
    ThePants999:
    It "optimizes for memory usage" by creating a 10-element list to hold boolean values...
    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

    You got FILE_NOT_FOUND, I see, but you left out VERYTRUE and VERYFALSE.
  • (cs) in reply to DaveK
    DaveK:
    snoofle:
    ThePants999:
    It "optimizes for memory usage" by creating a 10-element list to hold boolean values...
    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

    You got FILE_NOT_FOUND, I see, but you left out VERYTRUE and VERYFALSE.
    Gahh. And *I* forgot FAIRLYTRUE and FAIRLYFALSE. D'oh!
  • (cs) in reply to DaveK
    DaveK:
    snoofle:
    ThePants999:
    It "optimizes for memory usage" by creating a 10-element list to hold boolean values...
    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

    You got FILE_NOT_FOUND, I see, but you left out VERYTRUE and VERYFALSE.
    Also UNKNOWN, MAYBE, SEG_FAULT, THE_FUTURE_IS_UNCLEAR, TRY_AGAIN_LATER and PAULA
  • Paula Bean (unregistered)

    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.

  • sdfsqdfqsdfsqdf (unregistered) in reply to SoulReaver
    SoulReaver:
    they could have used (OurBoolean.TRUE.toUpperCase.equals(result)) instead of (result != null && result.toUpperCase.equals(OurBoolean.TRUE))

    That would mean that reqult.toUppercase() is always equals to result.

  • (cs)

    Considering that this is used to check values from the database, there probably should be one for "NULL".

  • Phil (unregistered) in reply to snoofle
    snoofle:
    ThePants999:
    It "optimizes for memory usage" by creating a 10-element list to hold boolean values...
    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

    good, but you missed out

    1. TrueFalse
  • SomeCoder (unregistered)

    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.

  • (cs) in reply to Phil

    Fixed:

    ThePants999:
    It "optimizes for memory usage" by creating a 10-element list to hold boolean values...
    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

  • G Money (unregistered) in reply to snoofle
    snoofle:
    ThePants999:
    It "optimizes for memory usage" by creating a 10-element list to hold boolean values...
    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

    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"

  • El Dudarino (unregistered)

    The real WTF is that they used List instead of ArrayList.

  • (cs) in reply to G Money
    G Money:
    snoofle:
    ThePants999:
    It "optimizes for memory usage" by creating a 10-element list to hold boolean values...
    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

    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"

    shudders

  • El Dudarino (unregistered) in reply to El Dudarino
    El Dudarino:
    The real WTF is that they used List instead of ArrayList.

    Hey wait... They DID use ArrayList!!! This code is just fine...

  • (cs) in reply to El Dudarino
    El Dudarino:
    The real WTF is that they used List instead of ArrayList.
    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!
  • (cs) in reply to El Dudarino
    El Dudarino:
    The real WTF is that they used List instead of ArrayList.
    You mean because such obviously idiotical programmers managed to get one thing right?
  • Bob (unregistered) in reply to snoofle
    snoofle:
    ThePants999:
    It "optimizes for memory usage" by creating a 10-element list to hold boolean values...
    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 "tr...

    You didn't allow for typos.

  • Philippe (unregistered) in reply to JL

    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...

  • Bob (unregistered) in reply to snoofle
    snoofle:
    ThePants999:
    It "optimizes for memory usage" by creating a 10-element list to hold boolean values...
    What in the world makes you think that the default allocation of <10> is anywhere near enough to store a boolean value?

    You left off "flase"

  • Michael (unregistered) in reply to SoulReaver
    SoulReaver:
    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))

    if result = "true";

    then (OurBoolean.TRUE.toUpperCase.equals(result)) becomes ("TRUE".equals("true")), your way fails.

  • Militis Sanctus (unregistered)

    ...just...wow...er...wow

    Man this Initrode place is popping up all over the WTFs

  • Paul L (unregistered) in reply to gabba
    gabba:
    And by calling it OurBoolean, he makes everyone responsible for this gem, not just him.

    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.

  • BinaryPhalanx (unregistered) in reply to snoofle

    You left out a couple:

    YEs yES yEs nO

  • (cs) in reply to Michael
    Michael:
    SoulReaver:
    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))

    if result = "true";

    then (OurBoolean.TRUE.toUpperCase.equals(result)) becomes ("TRUE".equals("true")), your way fails.

    Not to mention that toUpperCase on OurBoolean.TRUE is, well, kinda silly?

  • Harry (unregistered) in reply to snoofle
    snoofle:
    ThePants999:
    It "optimizes for memory usage" by creating a 10-element list to hold boolean values...
    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

    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.

  • rycamor (unregistered) in reply to snoofle

    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
    
  • kwilliaa (unregistered) in reply to snoofle

    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' ...

  • (cs) in reply to ThePants999
    ThePants999:
    It "optimizes for memory usage" by creating a 10-element list to hold boolean values...

    Obviously you're not aware of the "time-memory" tradeoff.

  • (cs) in reply to G Money
    G Money:
    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"

    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.

Leave a comment on “OurBoolean”

Log In or post as a guest

Replying to comment #:

« Return to Article