- 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
Duh. Obviously an uppercase 1 is !
2 = @
3 = #
You get the picture [:P]
Admin
My first thought is that perhaps he is checking if the Ignore Case of an Approval Type Code is a particular case. Magic numbers sure, bad.
But somehow I'm guessing that it is a case insensative string compair....
Admin
Beyond the obvious but harmless WTF:
How about a variable to hold secApp.getApprovalTypeCode()?
And it should be "1".equals(... to avoid null pointer exception, assuming this is Java.
Admin
Well, of course the number does not have upper/lower case. But he is checking, in case the getApprovalTypeCode return does, duh!
dZ.
Admin
This functionality is necessary because in the future people will start using lowercase numbers.
Admin
Oh, and by the way, don't flame me; it was a joke.
dZ.
Admin
thedailywtf.com is the forum where so-called "masters of their domain" people pore over poor, wasted, (illegal), illogical, unoptimized, lengthy code for hours and offer comments, correct code, thinking that they are the Founders of The WTF? phenomenon, with the ultimate command of their skills.
...while their productivity in their workplaces is often measured in single digit scores, and the time that they waste in poring over the poor, wasted code could have been best spent on good, improvisable code.
Don't ask why I am wasting time now...
Admin
slow wtf week huh
Admin
OMG! that is funny!
Admin
So why are you wasting your time now?
No, but seriously, how much you want to bet this guy is the writer of today's WTF? [:P][:P]
Admin
It's probably to tell the difference between 1 and <font size="6">1<font size="3">.</font></font>
Admin
The numbers in caps:
ONE!!!!
TWO!!!!
...
NINE!!!!
After all, capitals are just shouting, right? I guess what this means is that this program cleverly counts "ONE!!!!" and "1" as equal. Quite an elegant solution.
Admin
He probably did it because of bad experiences with uppercase booleans...
Admin
In Java, (at least last time I checked) equalsIgnorCase performs better than equals.
Admin
I think that this is absolutely brillant!
Admin
How's that?
Admin
I was thinking the exact same thing...
-ds
Admin
There's always some douche-bag that feels the need to waste his time chiding others for wasting theirs. It's pretty stupid, especially when its's done with a sanctimonious tone like the above.
Admin
That's technically impossible unless the implementation of String.equals is a WTF in itself.
Admin
There's always some douche-bag that feels the need to waste his time chiding douche-bags who chide others for wasting their time. :-)
ObMontyPython: I know I'm not, and I'm sick and tired of being told that I am.
Admin
Since I am already an admitted time-waster, your time is wasted writing the above.
Admin
Oh oh! I know! He should've used a switch statement!
Right? Right?
Admin
Thats not funny. Back in college I once caught myself writing a 9 while pressing really hard on the paper where the 'shift' key would be. Sadly my pencil didn't understand such notation and produced a 9, not a ( like I obviously wanted...
I caught this because while looking over my answers some didn't make sense so I was re-doing them carefully. Fortunately it was one assignment so it didn't cost me a grade, and it gives me this really err... interesting... story to tell.
Admin
Obviously, we need to replace the type code with inheritance and move this method to the secApp object.
Admin
It doesn't, especially for long Strings. While equals() does use the instanceof comparison operator, equalsIgnoreCase calls Character.toUpperCase() AND Character.toLowerCase() on every single character of both Strings, unless it finds one that doesn't match.
if (ignoreCase) {
char u1 = Character.toUpperCase(c1);
char u2 = Character.toUpperCase(c2);
if (u1 == u2) {
continue;
}
if (Character.toLowerCase(u1) == Character.toLowerCase(u2)) {
continue;
}
}
Admin
This is even worse than you'd think, since Character.to{Upper,Lower}Case() are locale-dependent, which makes them hideously slow. If you're writing, say, a compiler for a language with case-insensitive identifiers, your best bet is to downcase all identifiers as soon as you see them, rather than doing case-insensitive comparisons all over the place.
Admin
"Master of their domains ... hours"? More like "newbies with a clue ... minutes".
I don't even code in the languages represented here and I see the WTFs right off ...
OHHHHH. Whoops. I missed the <sarcasm> tag there.
Never mind.
Admin
Were you on acid?
Admin
I think its more of a Java thing. I recall reading that inherited methods are somewhat inefficient in java, in that String.equals() [which overrides Object.equals()] will have a higher overhead than String.equalsIgnoreCase() [because it is only declared for String].
In practise, it depends on the environment and on the version of java you are using, but equalsIgnoreCase can be faster when dealing with very small (1 or 2 character) strings.
Even if I misremembered, I don't think such a simple oddity is worthy of being called a WTF. Maybe the code used to be a letter, and they changed them to numbers without changing the code. (Actually, that's probably a Bad Thing in itself, but I wouldn't think it deserves to be a WTF.
(Wow, my CAPTCHA for today is 'random'... self descriptive spamblocking)
(except that when I hit "post", it says its wrong. Now its 'image'... self descriptive again)
Admin
Even simpler than a compiler...any global web application. At my last company they preached i18n through the whole dev cycle, yet there are ASCII depenedent comparisons all over the app.
Admin
What's 'improvisable' code anyway? I'm not even sure 'improvisable' is a word.
Admin
I think it falls into one of these categories:
http://www.dcc.unicamp.br/~oliva/fun/prog/resign-patterns
Admin
This is nonsense. Java method lookups go from the most specific up the heirarchy. Even if the compiler did apply some optimization to equalsIgnoreCase method call, it's going to be miniscule in comparison to extra work required for an equals ignore case comparison.
There are so many myths about Java it's unbelievable. They seem to have reached this critical mass where they cannot be stopped.
Admin
Great link. The 'Absolver' and 'Chain of Possibilities' really apply to my current work.
Admin
Wrong tho; it's obviously region specific. Here, uppercase 2 is '"' and uppercase 3 is '£'. (Incidentally, the caps lock key on some old typewriters was actually a shift lock ;) )
Admin
This is certainly the weakest WTF I have seen since I started reading this site.
Admin
Not a huge WTF.. on modern machines, with Strings with lengths of one, using the equal instead of the ignoreCase will yield about 0.15 second difference... For every million call! :P
1 000 000 iterations: 15ms for equals, 172ms for ignorecase,
I've seen MUCH worst than this!
Admin
First, that's no joke in certain cases. Besides that, though... it's just STUPID. The programmer is obviously an idiot doing copy-and-paste with no real understanding.
Admin
At my current job, from which I have just given my two weeks notice, I was told to "use less classes". I created a class called ${SomeDomainSpecificGarbage}Adopter. This was not questioned at code review, and is now a part of our (soon to be their) production code. Truly a resign pattern in this case, and a WTF to call my own!
Admin
The WTF are not only related to the slowness of the code, but also if the code is idiotic.
Admin
So it's an Adopter pattern wrapped that will become an Absolver pattern when you're gone. It's always nice to leave a steaming pile for the next guy.
Admin
Oh come on, it is a perfectly cromulent word.
Admin
I also see a lot of the Simpleton pattern.
Admin
That means?
Admin
<FONT face="Courier New" size=2>that's the most awesome thing i've heard all day.</FONT>
Admin
Simpson's reference
http://en.wikipedia.org/wiki/Cromulent#Cromulent
Admin
I meant what does 'improvisable' mean.
Admin
The article on "cromulent" should have explained.
Admin
Believing that Equals with or without comparing case will have any sort of noticeable performance impact is just laughable. People care about performance at all the wrong times. :p
This code is not a WTF. Perhaps it is reading keys from the keyboard, and at some point he might want to change a key binding from a '9' to a 'P'. If this was a possibility, he is 100% correct to use ignores case. Especially so, if changing the key bindings is a common operation, or if they might want to extend it into the future to perhaps read from a .cfg file. Otherwise they make a trivial change and the code breaks.
There's nothing wrong with this code, especially if its within the context of a larger switch statement.
-Bill Kerney
Admin
this 'guy'??
dude! How the hell did you guess correctly!
I am a guy!!!