- 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
This post contains strings for all possible posts that WTFers could wish to make.
Oh, and Frist!
Admin
String First='Second" print(first)
Admin
public static String _COMMENT = "comment";
Admin
This is obviously going to save you tons of time in an IDE that has code completion, because you would only have to type '_W' and then CTRL+SPACE and then use the down arrow to scroll through the choices and pick '_WY'. This is obviously much more efficient than just typing 'WY' - DUH.
Admin
All you really need is the correct indices to get the proper substring out of public static String _PI_COMPLETE.
Admin
function makefirstpost() { $f = 'f'; $i = 'i'; $r = 'r'; $s = 's'; $t = 't'; $ep = '!';
$captcha = 'conventio';
$return = $f.$r.$i.$t.$ep; return $return }
Admin
What are the criteria for a number to qualify as a constant? Even though the file had many constants, there are even more numbers left to add to the file. I hope they look in to this. ;-)
Admin
public static String _GREATER_THAN_OR_EQUAL14 = ">=14";
This is just good practice. It completely removes the ambiguity of the magic number 14 in your code. _GREATER_THAN_OR_EQUAL14 is much shorter than typing out >=14 EVERY TIME you want to do a comparison to 14. This will also ensure that I don't punch the programmer in the ear when I find out who wrote it.
Admin
A frustrated COBOL programmer acting out?
Admin
Looks like someone had their IDE setup to error on all non-constant Strings in the code. If that's not the case, then the insanity is truly setting in.
Admin
_W _T _F
Admin
Admin
compile error.. mismatched quotes
Admin
and even when fixed: Symbol not found: first
Admin
I'm calling "Shenanigans" on this one. No one would work with shit like this.
Yeah, right.Admin
<%=class_1821._TDWTF_COMMENT %>
Admin
The real WTF :
The sophisticated incrementing system of naming classes leaves us with a class name like '_1641' when there are only 552 classes.
Admin
And to top it off, the "constants" aren't even constant...
Admin
Fear not... since they're not constants (final keyword), you can assign the right value afterwards:
_1641._AK = "AK";
And everybody happy! Right?!
Admin
I think that refactoring could make it right:
public static String _GREATER_THAN_OR_EQUAL14 = _GREATER_THAN_OR_EQUAL + _215._14;
Admin
In the precursor of my current project (huge financial app) there was a "Constants class" like that too (actaully a "constants interface", a practice considered a WTF in itself by some, though I don't see it as all that bad). The contents weren't as idiotic as this, but it still was (or became) a huge WTF. Since every single one of the about 5000 classes in the project used that interface, or used another class that used it, a full rebuild of the entire project (automatically if eclipse was set up that way) was triggered whenever you had to add a new constant. It took about 15 minutes on a brand-new workstation.
Admin
It must be. COBOL is the only language that I know of where it's possible to have a negative zero. (And, yes, it does not equal zero!)
public static String _AUTO_STTS_OIE = "-0";
Admin
Am I the only one who caught the Zork reference? Seriously, isn't ANYBODY going to be eaten by a grue?
Admin
The REAL WTF here is that the author didn't use the constants in defining the other constants. He should have written them like this:
public static String _GREATER_THAN_OR_EQUAL14 = _GREATER_THAN_OR_EQUAL + "14";
That's ELEMENTARY software engineering!!
Admin
Personally, I think that's pretty awesome. I can never remember which symbol is greater than and which one is less than (The aligator eats the bigger number, right?). So this way, I just have to remember _5._GREATER_THAN...or as a backup -- in case one forgets _5 -- there's also _83._GREATER_THAN.
What could be simpler than that?
Although, it would help if someone had added something like the following: _9347._Captcha = "feugiat";
Admin
... Did you just inflict PHP on an unsuspecting crowd? That's 15 Hail Mary's!
Admin
public static String _EQUAL = "=";
Depending on the language used, I forsee problems with this...
Admin
Of course not, they're in a sunny meadow. Everyone knows that the grue only eats you if you enter a dark area without a light.
Admin
552 classes, incrementally numbered, so around 1090 must have been deleted - they really should have finished what they started and got rid of the remaining 552.
Admin
public static string _RANDOM_USER_COMMENT = "WTF Batman?!?";
seriously though, this looks to me like a perfectly reasonable "best practice" that was enforced by a clueless idiot who was promoted after the actual designer left.
Admin
System.out.println(_1269._F+_1269._I+_1269._R+_1269._S+_1269._T);
Admin
public static String _AK = "AB";
This is not a bug -- actually, it demonstrates the power of the technique. Obviously, new application needs have necessitated redefining the string "AK" to "AB". This way it only has to be changed at one place. Duh.
Admin
No, good practice would be defining a constant with value 14 whose name indicates what it means. _GREATER_THAN_OR_EQUAL14 is no different than typing >=14. Neither tells you anything about why you are comparing to 14.
Admin
Yeah, it really sucks when that happens.
Admin
Java's Double class treats -0.0 and 0.0 as different numbers.
Admin
The more you know! (Shooting star going across the screen)
Admin
Actually I just think it means that whoever they were trying to mail stuff to moved from Arkansa to Alberta. So not a WTF
Admin
Whee!
Admin
public static class _1337_UK extends _1337 { public static String _FULL_STOP = _PERIOD; }
Admin
One of the great things about this site is having the opportunity to educate young developers as they start out on their career.
Constants are something you should use to make your code more readable, and it is a good idea to keep them all in a central location.
I am not a Java programmer (although I am sure it would be easy for me), but I have chosen to go into the more lucrative field of Visual Basic, since it is higher demand and has more room for promotion. Anyways...
In VB, I like to put constants anywhere that the value could change. For example, in our ordering system, I have all the sales tax codes as constants, so if they change, all I need to do is whip open Visual Studio, make one change, recompile and I'm finished, no big deal.
If you are a DBA, and not a developer, you might ask why do I store them as constants rather than in a database (and beleive me I have had to fight this fight), the answer is it takes less time to re-compile my application, than submit a database change request and wait for the DBA union to run my update script.
So the lesson I want to leave you with, it is often best to store data as constants or variables in code that YOU CONTROL than it is to store it in a database that you have no control over.
Admin
public static String _MEANING_OF_LIFE_UNIVERSE_EVERYTHING = "42";
Admin
_WY indeed...
Admin
Admin
On IBM mainframes decimal and packed decimal data types can represent negative zero. Other languages used on mainframes can do it as well. And Python can do it too:
Admin
How about the use case where I control both the DB and the code, but am just too lazy to make the change in the DB?
Admin
Admin
I'm not sure to agree with you. Constant shouldn't be in a central location. They should be at a place where they make sense and where you expect to find them. If your projets implements HTTP and FTP, the HTTP and FTP constants must be defined in their respective classes. If your company connects to different servers to sell potatoes, the server default port should be defined private in StoreSocket and the potato price should be defined in Potato (or Item, depending the level of OO you implement).
Admin
"OK, now open your eyes. Which code file was it? If you're like me, then it was a preliminary collection of constants and enumerations based on the business requirements"
I'm happy to report that I am not like you and I would never had started with such a file. Most likely I would have never introduced it to the project. If someone else would try doing so, I would actively fight the idea, because it introduces coupling between otherwise unrelated parts of the software. Unless of course, these parts are already related (but then we are not talking about centralized collection of constants and enumerations anymore).
Lots of (lost) programmers love to start new projects, but only to scribble some ideas on the clean canvas, with very little thought given to actual design.
Admin
Back in my hobby days, I once wrote a game where I needed a constant that tied everything together. It had to do with size of int, extent of the game area, color depth of the screen, speed of the processor and user's angle of view. If memory serves me correct, the constant was in the high teens. Good times.
Admin
Beautiful example of constant abuse - one that negates almost every benefit of constants. I used to use 'constant interfaces' in Java because I saw the technique used in the Java framework and assumed it was an acceptable practice. It wasn't, as it turns out.