- 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
Ultimate frist!
6am UTC is quite early, indeed.
Long live the power of notifications!
Admin
Filed under: I shouldn't have gone to the "Official Likes Thread" straight away...
Admin
The HTML is nicely borked.
Admin
I hate you guys
Admin
Remy accidentally the whole thing. Maybe he should've used CONSTANTS to create the source code?
Admin
They could be there to facilitate translation (including into another dialect of SQL...)
Admin
Hmm. Reminds me of http://c-faq.com/cpp/slm.html
Admin
This should be The CONSTANT Gardener with the obvious metaphor being that this is cutting through the overgrown weeds that were put there by another gardener who thought this is what a garden was supposed to have in them.
Admin
Come on... who hasn't done this?
Admin
Hmm, the bot has got a bit excitable again.
Admin
I wonder what would happen if they release a non-english version someday ...
Admin
SETTLE DOWN PAULA! We don't have your beans!
Admin
Well that's annoying. The space for the 'like' text isn't pre-allocated so as each post gets liked it jiggles the screen around as the size changes. Great idea for a floating design.
Admin
Does anybody know if this topic is visible yet? I'm not sure if it will be displayed in topic lists
Admin
public static final String NUM_TIMES_TO_MAKE_ARTICLE_VISIBLE = "BRILLANT!;
Admin
There's no way of knowing for sure.
Admin
Now wait and watch the likes topic when someone catches up on likes and you'll see the page moving while you wait - because it updates it pretty much live. Great fun if you're typing at the same time and what you're typing is scrolling off the screen.
Admin
I disagree: https://www.youtube.com/watch?v=aCbfMkh940Q
Admin
Holy cow, I just noticed there's something vital missing here!
What about
?
Admin
Admin
Admin
TBH, not all of the strings are ridiculous as A_TEXT = "A". The abbreviations for package names and procedures are not so bad, and some strings might occur more than once in the code, making replacement easier. It's not the preferred way to do I8N though.
Admin
Ok, just my 2% on yet another "make everything a constant" article.
Why
public static final String ZERO = "0";
is definitely overdoing it, the code featured is what you get if your coding rules include something like "magic numbers or string literals in the code are not allowed".You ask for accumulating stuff in one place as consts, you get it.
The second reason such code exists (been there, done that, still do occassionally) is when you work in an environment where demands like "I don't like the sentence in the button there, it contains to many "o"s. Change it!" are made regularly and have to be dealt with by whoever is available.
In that case, you const all string literals and place them in one well-known file simply to make life easier for the poor fellow tasked with changing the text.
So, some minor wtfs in the first part, but I don't really see the long list of const'ed string literals as a wtf. Sorry.
Admin
TRWTF
public static final String secretKey = "mE3BrW5B";
Not so secret any more :-)
Admin
And this is what happens when you're typing HTML in a richtext editor and it sticks <p> tags in places where they shouldn't be.
Admin
Sorry to disagree man, but that's what resource files are for. Java must have an equivalent (only more enterprisey). In fact, yes it does.
Constants are a simple/low tech/crude way of doing things, but once you have to support multiple languages you're screwed unless you're going to branch the file, or come up with a more complex solution, in which case you may as well just use resource files anyway.
The other advantage resource files have is that you can make spelling changes without needing to recompile the whole application.
If anyone tried to check something like that in here, I'd slap them up the side of the head and make them wear the cone of shame for the rest of the week.
Good spot old boy!!! I would double like this if it were still possible.
Admin
Oh man... I just can't unsee this.
And as someone else pointed out, what about resource files? I haven't done any Java since 1996, but in .NET that's where we put all our text (especially since the applications we write have to be multilingual).
Admin
public static final String disposition = "Content-disposition";
public static final String dispositioninline = "inline; filename="";
public static final String conappndone = "/";
public static final String conappndtwo = """;
public static final String contypetwo = "application/octet-stream";
public static final String dispositionattachment = "attachment; filename="";
Admin
Every noob programmer go through initiation ritual. They will create constants that will muddle the code.
Admin
It is my understanding that this topic is now visible. It will be displayed in topic lists.
Admin
That's also how you'd do localisation in Java. Except in this case it seems, where you localise by editing the
secret keydatabase insertappropriate constant in this source file.Admin
This looks kind of like the result of a heavy-handed coding practice of NO LITERAL CONSTANTS ALLOWED IN THE SOURCE CODE, ALL CONSTANTS MUST BE NAMED, NO EXCEPTIONS.
Admin
I still can't believe that, what a dumbass!!1!1!
Filed under: wait, was this taken from the Discocourse source?
P.S. Discocource source is quite fun to say
P.P.S. I know it couldn't be from the Discocourse source because it's the wrong language, but that'd just be a barrier to making fun of Discocourse
Admin
Am I the only one who wonders if the author of this code ever heard of abstract classes?
Admin
+1 QFT.
Admin
I'd say that's a disadvantage.
http://xkcd.com/303/
Admin
printf(SUBMENU_WHOSON, "FRIST");
Admin
Admin
That "class Constants" is truly amazing. We have COBOL copybooks like that...but then you either do that in COBOL or else you define the constants in every program...which, oddly enough, has a downside...
But it's pretty clear that the creator of "class Constants" was a programmer from some environment such as COBOL, because there are much more logical ways to store constants in an OO systems.
Also, I think you should do an article on how constants are used. Take this constant:
Ok. So then why do we have...
Admin
I was all kinds of going to read your post, but then I saw COBOL and SQL in the same block of code. It supports that?
Next thing you know it's going to be supporting things like variable length strings.
Admin
Well if it didn't I guess the most respectable bank systems would not have databases at all! For shame!
Admin
Oh man.
The COBOL I used had a flat file database backend. Maybe it was even proprietary.
So I had no way of knowing.
Admin
Admin
It's not enterprisey enough. The constants should be base64-stored in elements of an XML document, printed out, placed on a nice, clean wooden table, photographed, scanned, attached to a Word document, emailed, screenshotted, and finally stuffed into BINARY fields on a database.
Admin
Admin
I feel like I need to bill someone after reading that. Bonus points for
Admin
Is @PJH awake yet?
Admin
For the date ones, I can understand what they were attempting, but they were a bit off.
DATE_TIME_PATTERN_FULL
isn't really descriptive towards the usage, only what it is, which should be easily identifiable from looking at the date format specifier. But if you have something likeFILENAME_DATETIMESTAMP
, it makes sure that you have a consistent approach to naming files based on dates/times.And there's no doubt that
FOOTER_TIMESTAMP
is a WTF, since it's either used once in a footer snippet of code, or it's copypasta'd in every place that has a footer.Also, what happened to H, J, K, L, N, O, Q, U, V, W, X, Y, and Z?
public static final String JAVA_EXCEPTION_CODE = "9999";
..........because I think of magic numbers when working with exceptions, not errors. I can't remember why these are a WTF in Java, I just remember that people always complain about them, and make me glad that I never touch Java.Admin
Been awake for ages. Why?
Admin
This topic needs a bit of cleanup.
Is this for the Baltimore airport? o_O
EDIT: probably not, unless it's just a European developer for BWI.
public static final String MENU_BESTCHEQUECOMM = "BestCheque Commissions";
Or it could be 'Murica:
public static final String MEM_SRCH_PROMO = "NASCAR";
public static final String MW_FG_BWR_ERROR = "Exception occured during submission.";
#WHY DOES NO DEVELOPER KNOW HOW TO SPELL THIS!?!?!?!!?public static final String E = " E ";
shouldn't that be
SPACE_E_SPACE
?public static final String MODIFY_RATES_UI_NBSP = " ";
Much different than any other
.What if you need
REPORT_FORMAT_TWO
?public static final String DELIMITER_EQUAL_TO = "=";
Silly developer, using Java, it should obviously be:public static final String DELIMITER_EQUAL_TO = "==";
public static final String SPACE_160 = " ";
So if the space character suddenly changes and becomesŸ
, will the code need to be refactored toSPACE_159
?I like how both of these are strings when they should simply be values.
NULL
should benull
, not"null"
, and I assume that the logout URL is referenced as something likeConfig[LOGOUT_URL_KEY]
, but that's just going a bit too far.