- 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
wow that is really something to be proud of right there.
Admin
It's enterprisey!
Admin
Sounds like LOC to me.........
Admin
Some one got paid by the line.
I hope....
Admin
At least it's well-commented!
Admin
Holy crap! Is this some kind of joke? This is beyond brillant levels of productivity. How did this happen?
Admin
True that!
I bet its done by pay per line.
Admin
OK then. I guess it was a slow day at the office and David's colleague felt the need to spend the entire day reinventing the wheel.
Also is funny how he feels the need to have 20 character long constants to represent the numbers 1, 2, 3 and 4.
What happens if the binary number has more than 4 bits?
I guess this function wouldn't work eh...
I cannot immediately detect any logic errors in this so I guess he should be congratulated for at least reinventing the wheel without creating any fatal flaws in the application.
Also, I doesn't look like this was really 5000 lines of actual code. There are a lot of lines being taken up by useless comments and a lot of whitespace. This probably could've been done with only 1000 lines of code.
This one is a little bit of a letdown compared to the highly entertaining WTFs of the past 2 weeks.
Admin
Brilliant!
Well... not really... he actually did 5000 LOC
what about being paid per lines?
Admin
If only Java had provided a way to loop, he wouldn't have been forced to do it with nothing but if statements.
OH WAIT, IT DOES HAVE LOOPS!
Admin
i bet I could do it faster by hand than this code ... where the heck was the manager ... hmm maybe he was the manager and thought he was the best programmer in the world ..
oh well, I hope this programmer was given the old yeller for this hideous creation
Admin
Someone wasn't too pleased to get fired I guess :P
Admin
It's difficult to type a response when your eyes have melted out of your head from looking at code like that.
Good thing it's Friday. I have all weekend to recuperate.
Admin
<font size="2">Deal Lord in Heaven. At least it's nicely commented. I especially like how he keeps referring to "an hexadecimal". When did the 'h' become silent?
</font>
Admin
<font size="2">Er, that would be "Dear Lord", of course.
</font>
Admin
This is my favorite line. So descriptive, not only in name, but also in documentation.
Admin
This must be cockney code!
Admin
<font size="2"><font size="1">public static final String HEX_CHARS = "0123456789ABCDEF";
public char convertBitsToHexadecimalCharacter(boolean bit1,boolean bit2,boolean bit3,boolean bit4) {
return HEX_CHARS.charAt((bit1?8:0)+(bit2?4:0)+(bit3?2:0)+(bit4?1:0));
}</font>
Oh forgive me, I had to write this to fix my eyes...
</font>
Admin
I want to see his Octal class.
Admin
The tears from my laughter just shorted out my keyboard. I had to get a new one.
Admin
I think that is proper British english. I'm not 100% sure, but I know I have see "an" in front of 'h' words quite a bit when reading british articles and literature. Older english literature especially.
Admin
I remember Eclipse's auto-generated comments looking like this.... After all, if one has to write 5000 lines of meaningless code like this, it helps to save some time by having your IDE generate your comments for you :)
Admin
My personal favorite is
static final Char[] hexChars="0123456789ABCDEF".getChars(); char toHex(int val) { return hexChars[val&0xF]; }
and then use varieties of it in a loop to convert however many you need
though of course Java provides String Integer.toString(int value, int radix);
(and no, I'm not going to use IE just so I can add formatting to this)
Admin
about 'an hour' ago. :p
Admin
Oh, and in C its even more fun
char toHex(int val) { return "0123456789ABCDEF"[val&0xF]; }
Admin
There is a first time for everything. And today is the first time I feel I must claim that this WTF must be made up.
We are getting close to April 1, after all.
I've seen many people re-implement functionality Java already provides because they think they can do it better. I've seen it so many times I've practically memorized the tirade I give them at code reviews.
But this... this is so above and beyond the call of "I'd rather do it my way" that I just can't imagine anyone sleeping at night after writing it.
I can, however, imagine that whoever wrote it went on a campaign to try to get everyone else on the team to use it wherever the need to convert bytes to hex strings arose. Bad frameworks are as common as fungus and about as resistant to being cleaned up.
Admin
He forgot the *hiccup* notations to indicate his drunkenness.
Admin
oh my hat that hurt. It burns!
Admin
I can't help but feel that this is an example of how a person can be intelligent and educated regarding computers and programming, but doesn't have that creative "something" that makes a truly good programmer. Yeah, it compiles and yeah, it works, but...
I liken it to somebody who really, really wants to play the guitar, but doesn't have a lick of innate creative capacity for it. They can practice their brains out for years, but never be more than an ordinary hack. I've seen this before. My cousin is/was a musical virtuoso who could play practically any instrument you handed him extremely well. My older brother, OTOH, loves music dearly and has practiced and played the guitar for over four decades, yet is, to put it charitably, "adequate" at it.
Admin
Oh, I thought you were talking about the Patron Saint of Car Salesmen.
Admin
Oh, I thought you were referring to ebay.
Admin
lol
Admin
Looks like the work of a person who didn't know anything about Programming, sat through two lectures of Haskell, and never quite got hang of these Leet Advanced Features...
There's functional programming and then there's functional functional programming.
Admin
Admin
Yes, and surely not by reusing the code. Instead it should be copy-pasted everywhere it's needed.
More effecient to do it in-line, you know.
Admin
This looks like a practical joke from an unfortunate programmer whose performance is measured in LOC per day and who is tortured with overly strict requirements regarding comments, constants etc.
Admin
For whatever it's worth, this is what I did once...
#ifndef ASM_HEXIFY
const char hexchars[] = {48,49,50,51,52,53,54,55,56,57,1,2,3,4,5,6};
# define hex_low(what) (hexchars[((what) & 0x0F)])
# define hex_hi(what) (hexchars[(((what) & 0xF0) >> 4)])
#else
# define hex_low(what) hex_low_asm(what)
# define hex_hi(what) hex_hi_asm(what)
#endif
...and before you complain about the character values, remember that all the world is not ASCII. =(
The assembler version of these routines sucked for some reason or other...
Admin
Hey, I've spotted another WTF: they did not declare constants for lowercase numbers ;)
public static final char lower_1 = '1';
That would be priceless.. Also, more LOCs.
Admin
Something wrong with String.toHexString(int i)?
Admin
hey!!... truth is how you define it
besides, this makes it really scalable
Admin
If he gets paid by the line I hope none of his future employers see this code. Boy what a waste of time. Can you imagine the frustration he must have had when someone pointed out that he just has reinvented the wheel?
Admin
Only if the next word starts with a vowel, or a silent consonant. Eg: an apple, an hotel (if you don't pronounce the "h", as some people don't).
Admin
Today is a good example of how not to build enterprise class software. First, pick a language that is has a lot of hype around it such as java. Then, disregard all concern for performance, because we all know you can just through a faster machine at it. Finally, hire a skilled programmer and tell them that they will get paid by the number of lines of code they write, and that you expect them to comment every single line of code. The result will be a very slow, but easily maintainable piece of crap.
The above example was most likely generated by a programmer that was paid by the number of lines of code he or she produced. The programmer then creates a program to output this code in oh, lets say about five hours to give him or her time to debug, surf the net, and just screw around... After done with the generater, the programmer runs it, and then sits around for the next week doing nothing because they were able to make a program that wrote 5000 lines of code that is clean, commented, and technically correct...
Of course, we all know what we would have done had this project been our baby...
Admin
At 5000 lines of code, you would wind up with shorter code by writing:
for(int a; a=0; a < array.length())
{
switch(array[a]) {
case 0b00000001: ...
....
case 0b11111111: ...
}
...that would come to about 1000 lines. 1/5th the size for 256 times the stupidity. Despite the absolute terribleness of this implementation, what bothers me more-so is the fact that an entire class has been designed and declared for such a trivial procedure. In terms of overhead to benefit, this one outsinks the titanic.
Admin
Maybe he's french.
Admin
OMG I am not sure which I am laughing harder at..the WTF or this comment.
Admin
Guys, I'm putting this gem into my library of reusable code. Someday this piece will save my life.
Admin
Maybe he was speaking in pirate. "An 'exidecimal is upon us, ye lads. Hard to port!"
Maybe not...it was funny in my head though.
Admin
The rule is, use 'an' if it makes a vowel sound. So, 'an hour' (sounds like 'our'), but 'a horse'.
But I don't think 'hexadecimal' starts with a vowel sound, so the original point stands.
Admin
Nope. Modern British follows the same rules as American (i.e. you go by the pronunciation, "an hour" but "a hotel"). Traditionally there was a rule that where a word began with "h" and the first syllable was unaccented, then you'd write "an", so "a hospital" but "an hotel", but that is now obsolete and only used by the stuffiest pedants. No literate Briton ever wrote "an hospital".
As for the WTF... to think I was joking when I posted something vaguely similar in the other thread! (Though, to be fair, this is a billion times worse than my version...)