• Prime Mover (unregistered)

    protected static final boolean FRIST = "frist";

  • King (unregistered)

    It's not only true or false it's BOOLEAN TRUE or FALSE.

  • WTFGuy (unregistered)

    IANA Java dev, but does this actually help at all with the "truthy" and "falsy" comparisons, or is this 100% pure distracting noise?

    I'm casting about for something, anything, that might be a legit reason for this.

  • LCrawford (unregistered)

    There's Logical True and then there's Java's BOOLEAN TRUE

  • (author) in reply to WTFGuy

    100% noise. There are no truthy comparisons in Java.

  • (nodebb)

    Nothing to see here. It just looks like an old "C" coder got his hands on a more modern language that actually has native booleans.

  • Prime Mover (unregistered)
            protected static final int INT_1 = 1;
            protected static final int INT_2 = 2;
            protected static final int INT_3 = 3;
            protected static final int INT_4 = 3;
            protected static final int INT_5 = 4;
            protected static final int INT_6 = 6;
            protected static final int INT_7 = 7;
            protected static final int INT_8 = 8;
    
  • Shiwa (unregistered)

    Static fields for a limited set of related constants are considered bad practice in java. They should have used an enum.

  • Anonymous') OR 1=1; DROP TABLE wtf; -- (unregistered)

    It could be worse—they could have defined BOOLEAN_TRUE = false and BOOLEAN_FALSE = true.

  • (nodebb) in reply to Auction_God

    A very old C coder. C has had native booleans since C99.

  • (nodebb) in reply to WTFGuy

    I'm casting about for something, anything, that might be a legit reason for this.

    It's 100% useless noise, much like the classic C/C++ one:

    #define ONE 1
    #define TWO 2
    

    Y'know, because, like, magic numbers ("naked literal constants") are hard to understand, so we gotta use a name for the number.

  • Sole Purpose Of Visit (unregistered) in reply to Steve_The_Cynic

    THREE_POINT_ONE_FOUR_ONE_FIVE_NINE_ETC

    I'll bet some code base, somewhere, has something like that.

  • (nodebb) in reply to King

    Hey don't give them ideas. Next thing we'll see is going to be DECIMAL true and false, or even GUID true and false.

  • Yikes (unregistered)

    What about: BOOLEAN_MAYBE = (Math.random() > 0.5)

  • ooOOooGa (unregistered) in reply to Sole Purpose Of Visit

    | THREE_POINT_ONE_FOUR_ONE_FIVE_NINE_ETC

    I haven't seen that, but I did once see

    #DEFINE PI = 3.14591;

  • Argle (unregistered)

    I once encountered legit constants of ONE, TWO, THREE, TEN, etc. Legit how? It was ForTran IV. All parameters in ForTran IV were, in modern parlance, passed b y reference. Thus, if you called 'FOO(10)' essentially an unnamed variable was created to hold 10 and a reference was passed to the function. This being circa 1979, the computer in question had very limited RAM. Creating named variables for numeric constants actually saved an appreciable amount of memory.

  • Loren Pechtel (unregistered)

    Bad coder or bad management? I suspect the latter.

  • Simon (unregistered) in reply to ooOOooGa

    The system engineers at the other end had defined Radians as range -3.14159 .. 3.14159, so when we sent them 3.141592 they declared it out-of-range and shut down

  • Tim (unregistered)

    A colleague of mine recently wrote a 3000 spaghetti code class with plenty of constants like STRING_EMPTY = "", STRING_MINUS = "-”, ... I refused to even look at the code to find a bug but only offered a full rewrite.

  • Tinkle (unregistered)

    This is good forward thinking. It can be recompiled to run on a diskless node by changing this to: protected static final boolean BOOLEAN_TRUE = FILE_NOT_FOUND;

  • (nodebb) in reply to ooOOooGa

    Please tell me that they really did have the wrong value for (rounded) Pi and that isn't just a typo.

  • RLB (unregistered) in reply to ooOOooGa

    I haven't seen that, but I did once see #DEFINE PI = 3.14591;

    That would be because math.h, for some reason, still does not define M_PI. It's a GNU extension.

  • RLB (unregistered) in reply to Argle

    Creating named variables for numeric constants actually saved an appreciable amount of memory.

    Something very similar was common in large ZX Spectrum Basic programs.

  • (nodebb)
    Comment held for moderation.

Leave a comment on “Magically True”

Log In or post as a guest

Replying to comment #:

« Return to Article