- 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
Blink.
Admin
public static final char[] FILENOTFOUND = {'F','i','l','e',' ','n','o','t',' ','f','o','u','n','d'}; is missing!
Admin
I see the WTF. public static final char[] NaN = {'N','a','N'}; should be: public static final byte[] NaN = {'N','a','N'};
Admin
How does it even compile, can you switch on booleans and ints at the same time? It would work in C but in Java?
Or is it just a typo?
Admin
Oh My Lack Of God...
Admin
Yes, it is; look at the other cases. It's probably meant to be 16 << 0, though why anyone would type such a thing is beyond me.
Admin
WTF?
Admin
Admin
That's brilliant as I drop a massive shit.
Admin
No, that would be {14,'F','i','l','e',' ','n','o','t',' ','f','o','u','n','d'}.
Admin
So how often do they convert the MIN_INT_VALUE string to a number in a typical application, so they could compare other numbers to it?
Admin
My brain hurts! (Mmmm Braaains)
Admin
Admin
WTF ?
Admin
Why are chars [a-z] in in the char array intDigits? Is this being used for Base36?
The rest of the WTFs just look like someone having no idea how to code... at least in Java (or probably any newer-generation languages). This has the earmarks of an old-school mainframe coder.
Admin
It would be nice to know the context of this code.
It may be a part of some kind simulation of abstract machine or processor where those constructs make much more sense.
Admin
It hurts, it physically hurts. Why, why would anyone do THAT???
Admin
Simulation of Brillant Paula's brain? Now it makes sense!
Admin
Well if it had been written in C#, it would look much simpler because instead of
you can just write:
</Troll>Admin
My eyes! The goggles do nothing! Really, that hurts.
Admin
But, yeah, seriously, WTF? I'd really like to know the context of this project. Maybe it was a class assignment of some sort.
Admin
I don't suppose anyone could tell me what the hell this is supposed to do?
Admin
Admin
This is purely an experiment in entropy.
Admin
I'd really like to comment something witty and intelligent, but clearly I lack the cerebral capabilities to fully appreciate and comprehend the genius at work here. Someday.. someday..
Admin
Even my code isn't that f*cked up.
Seriously, as somebody who left programming eight years ago for a systems analyst role, I'd forgotten this simple truth about development in many corporate environments: Incompetence is immortal.
What I mean by that is that in most other functions, when something is built/done by somebody who is truly incompetent it will usually be replaced or repaired. But when it happens in development (and bad code makes it into production) it takes on a life of its own because nobody wants to touch the code (and rightly so).
Admin
In java you could write:
Admin
Hmmm.
I think this is the 14th Sign of the Apocalypse.
Admin
I wonder how many weeks he/she got off for worker's comp after their carpal tunnel surgery...
Admin
Pffft. You're being silly.
Admin
2nd.
This is just... GAH!
Admin
Just brilliant. This has got to be the best WTF: Programmer gave it a thought and dedicated considerable effort just to do something utterly wrong.
Admin
But why? Oh my! Why? WTF?!? Please, someone slap this person out of programming. I mean, this person and ALL of his team mates, because someone had to read THAT on a CVS/SVN changes email.
Admin
Ok, keep in mind that I'm only going to give a brief description of what this is supposed to do, not a) what it actually does nor b) why they did it.
In Pascal strings, instead of being null terminated (like in C e.g. c-strings), instead always have the length of the string as the first element of the array. This collection of what can only (and loosely at that) be referred to as "java statements" appears to be an attempt to implement this in java, perhaps so as to somehow interact with Pascal... for some reason.
Admin
Or even shorter (although a bit more complicated):
I don't see the point of making PSTRING_SIZE_OFFSET a constant if your code will only ever work if it is set to zero (the empty-string case).
Admin
Yo' C-pound ain't no array like tha Java be. Go home.
Admin
public static final char[] SMART_COMMENT = {'S','m','a','r','t',' ','C','o','m','m','e','n','t'};
Admin
Admin
Admin
On regard to the DigitTens and DigitOnes arrays, the bloke obviously wanted to do something like this (I'll do it in C because it's been a while since I last touched any java):
I wonder what will happen when the need to check for hundreds or even thousands arise. It probably will result in tendinitisAdmin
If I came across this in production code, I would refuse to edit it on aesthetic grounds (well, maybe retouch it so that it compiles, but that's it). I'd rather refactor all the other code that depends on it, to make inferior stuff work.
Admin
I'm glad to see that MIN_INT_VALUE goes to ELEVEN!
If I had to maintain this code I would definitely be looking for a cliff...
Admin
Who cares? It's Pretty :)
Admin
Fixed that for you. ;)
Admin
I like how each function is bracketed with }; because that's the face I make when I'm reading this WTF.
Admin
Oh.
My.
I tried gouging out mine eyes, and it didn't work. They still burn.
Wait. No. Mace. Mace'll do that to you.
Heed well, young Jedi: not even Mace can take away the pain of bad code.
Admin
Actually, the MIN_INT_VALUE doesn't go up to anything. They're using the 11 to tell you how many characters in the string '-2147483648', which is the minimum signed number in a 4 byte representation. That is why the other solutions about just initializing to a string won't work as this appears to have a requirement that the first 'char' actually be a number indicating how many more characters are in the string.
That being said, my amp goes to 12...
Admin
I hate it when I have to write code like that. I wish someone would invent a computer that could do arithmetic.
Admin
What kills me is that DigitTens and DigitOnes are only useful if indexed mod 100.
If the table is only useful if indexed mod 100, can I assume the author's knowledge of mod 100?
If the author knows how to mod 100, can I assume the author's knowledge of div 100?
If the author knows how to mod and div, then why, oh, why the arrays of digits?
Admin
Not only that, but when your code didn't work you could literally shuffle it around until it did.
In FORTRAN we always used the same variable names. That way, when you needed to add a line of code, you might already have it in one of your other programs so you could just dig through your old decks and find it. Saved waiting for a free 029.
We could put a lot of FORTRAN WTFs up here, but it would be shooting fish in a barrel.