| « Prev | Page 1 | Page 2 | Next » |
|
Duh. Obviously an uppercase 1 is !
2 = @ 3 = # You get the picture [:P] |
|
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.... |
|
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. |
Well, of course the number does not have upper/lower case. But he is checking, in case the getApprovalTypeCode return does, duh! dZ. |
|
This functionality is necessary because in the future people will start using lowercase numbers.
|
Oh, and by the way, don't flame me; it was a joke. dZ. |
|
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... |
|
slow wtf week huh
|
OMG! that is funny! |
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] |
|
It's probably to tell the difference between 1 and 1.
|
|
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. |
|
He probably did it because of bad experiences with uppercase booleans...
|
|
In Java, (at least last time I checked) equalsIgnorCase performs better than equals.
|
|
I think that this is absolutely brillant!
|
How's that? |
I was thinking the exact same thing... -ds |
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. |
That's technically impossible unless the implementation of String.equals is a WTF in itself. |
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. |
Since I am already an admitted time-waster, your time is wasted writing the above. |
|
Oh oh! I know! He should've used a switch statement!
Right? Right? |
|
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. |
|
Obviously, we need to replace the type code with inheritance and move this method to the secApp object.
|
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; } } |
|
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. |
"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. |
Were you on acid? |
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) |
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. |
What's 'improvisable' code anyway? I'm not even sure 'improvisable' is a word. |
I think it falls into one of these categories: http://www.dcc.unicamp.br/~oliva/fun/prog/resign-patterns |
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.
|
Great link. The 'Absolver' and 'Chain of Possibilities' really apply to my current work. |
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 ;) ) |
|
This is certainly the weakest WTF I have seen since I started reading this site. |
|
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! |
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. |
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! |
The WTF are not only related to the slowness of the code, but also if the code is idiotic. |
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. |
Oh come on, it is a perfectly cromulent word. |
I also see a lot of the Simpleton pattern. |
That means? |
that's the most awesome thing i've heard all day. |
Simpson's reference http://en.wikipedia.org/wiki/Cromulent#Cromulent |
I meant what does 'improvisable' mean. |
The article on "cromulent" should have explained. |
|
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 |
|
this 'guy'??
dude! How the hell did you guess correctly! I am a guy!!! |
| « Prev | Page 1 | Page 2 | Next » |