- 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
This is silly. Clearly the sort of thing should be done with a for loop.
Admin
Amazing. I did this when I first heard about programming but had never read a book or taken a class. I was 12 though.
First.
Admin
Well maybe second. =(
Admin
Ooh... he future-proofed it too!
Actually, YAGNI. Remove all, recompile, put back those you were using. That should remove nearly all of them. Then tell him to stop making dead code.
Admin
The best would be if setRecData with 23 arguments went and did something just slightly different from the rest. It could really weed out the men from the boys 5 years down the road when this piece of code was causing errors.
Admin
The REAL WTF is that the methods don't go up to 40. 40 rec data's is an absolute minimum for me.
Admin
Time to switch to Java 1.5+? Unfortunately switching these to varargs wouldn't maintain binary compatibility with any compiled code already calling them.
Admin
Like was said earlier, a for loop. Does Java have a params type for passing multiple arguments in the formal parameter list? This one is nuts!
-Max :D
Admin
...and he didn't code this via copy/paste either.
Admin
Throws Exception???
Admin
Anyone who actually uses these functions deserves exactly what they get if there is a bug in them.
Admin
Only asked for 20? Such lack of ambition, you should have gone for a much higher number.
Admin
You've found a magic bullet. Any time you want to get him out of the way so that you can work on code uninterrupted by him, just say "We need more overloads."
Admin
Clearly he should've used recursion.
BTW, Where's the definition of setRecData(String[])?
Admin
Yes, it does. This is just pathetic.
Admin
The goggles - they do nothing.
Clearly this guy must have been paid by the function.
CAPTCHA : venio - Venio, Video, Vicheo
Admin
public String[] bapp(String...strings) { return strings; }
?
Admin
But it's OPTIMIZED!
Admin
Do you really need a method to populate an array?
Admin
The real wtf is java.
Admin
I think the intention is to prevent callers from having to do this (prior to Java 5):
setRecData(new String[] { "a", "b", "c" });
Instead, they can do this (for up to 30 trios of string arguments):
setRecData("a", "b", "c");
In Java 5, of course, all this becomes unnecessary. Perhaps some newbie looked at this code and wondered, "WTF?!" It is all perfectly logical, even if it is overkill.
Admin
No, you don't. Actually, he creates new arrays all over the place, so...
Admin
If you ever see him walking around with an axe, run!
Admin
Wait... Java doesn't have variable-length argument lists ?
In C# only one overload would have been needed:
Admin
The real WTF is using arrays in Java.
Admin
TRWTF is that the article author thought we couldn't guess what code was produced the next day, and decided to paste over 4000 lines of useless text.
Admin
It does - that's what makes this a double-WTF. Either because he's writing all that code that is horrible and utterly unnecessary (you could replace those methods with a single vararg method and not even have to change any of the code that uses them). Or he hasn't heard of / isn't allowed to use a feature of Java 5, which came out in 2004.
Admin
Of course it does. The WTF wouldn't be that bad if it didn't. ...No, wait... it would.
Admin
You'd do it as follows:
The other WTF is the 'throws Exception', which is saying that something might go wrong in this method, but you don't know what, and you've removed the possibility for the user of the method to distinguish between compile-time and run-time exceptions.
Yet another WTF is, as mentioned, the use of arrays. There's really no good reason to use arrays in Java, except in a few special cases (such as converting a String into a char[]).
Admin
Coders with this disease cannot be dealt with using sarcasm. The only way is to confront them directly. If they fail to get the point, you clean up after them by deleting their useless code and hoping they get the point or escalate the issue to management.
Admin
Surely you mean over 9000
Admin
And the day after that Billy was given his pink slip, and there was much rejoicing.
Admin
Wrong. This code piece wouldn't be able unfold its full impression if it was cut down.
Admin
The TRWTF is Java ...
Admin
Maybe it's obvious to someone else, but why "c, m, p"?
Admin
And you guys laugh at VB.Net programmers?
Admin
Ahh, but who could have guessed our intrepid young hero would go to 30?
Admin
TRWTF is double posting
Admin
Admin
jared needs to tell that dude to java up!
Admin
Nothing but pitchforks and torches for people who write code like this.
I have had to clean up code that went on for approx. 250 lines just to verify that one (1) session variable had been set. Don't have that code to post, but wish I did to give you guys a good laugh, facepalm, etc. </soapbox>
Admin
There, does that make you feel better?
Admin
Admin
Mine goes to 11.
Admin
bows
Admin
Not unless it sparks another holy war...
Admin
How about asking him to make test cases for these functions. At least we would see how easily these "helper" functions are used.
Admin
Admin
Clearly you don't understand sarcasm.
Admin
Not sure that's much of a saving. Basically you have an extra "new String[] { " and an extra "}" to type in the first case, an extra burden that become completely insignificant as the number of arguments increases (it's a lot of extra guff for 1 argument, it's next to nothing for 30). Plus, you lose the ability of the caller to create the array in...I don't know....maybe a for loop instead of manually typing out 30 arguments. Or in other words, doing on the caller side what the function should be doing on the callee side.