- 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
protected static final boolean FRIST = "frist";
Admin
It's not only true or false it's BOOLEAN TRUE or FALSE.
Admin
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.
Admin
There's Logical True and then there's Java's BOOLEAN TRUE
Admin
100% noise. There are no truthy comparisons in Java.
Admin
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.
Admin
Admin
Static fields for a limited set of related constants are considered bad practice in java. They should have used an enum.
Admin
It could be worse—they could have defined
BOOLEAN_TRUE = false
andBOOLEAN_FALSE = true
.Admin
A very old C coder. C has had native booleans since C99.
Admin
It's 100% useless noise, much like the classic C/C++ one:
Y'know, because, like, magic numbers ("naked literal constants") are hard to understand, so we gotta use a name for the number.
Admin
THREE_POINT_ONE_FOUR_ONE_FIVE_NINE_ETC
I'll bet some code base, somewhere, has something like that.
Admin
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.
Admin
What about: BOOLEAN_MAYBE = (Math.random() > 0.5)
Admin
| THREE_POINT_ONE_FOUR_ONE_FIVE_NINE_ETC
I haven't seen that, but I did once see
#DEFINE PI = 3.14591;
Admin
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.
Admin
Bad coder or bad management? I suspect the latter.
Admin
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
Admin
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.
Admin
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;
Admin
Please tell me that they really did have the wrong value for (rounded) Pi and that isn't just a typo.
Admin
That would be because math.h, for some reason, still does not define M_PI. It's a GNU extension.
Admin
Something very similar was common in large ZX Spectrum Basic programs.