• Bobby tables (unregistered)

    This is silly. Clearly the sort of thing should be done with a for loop.

  • MP (unregistered)

    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.

  • MP (unregistered)

    Well maybe second. =(

  • Candy (unregistered)

    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.

  • Xenon Xavior (unregistered)

    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.

  • Alex (unregistered)

    The REAL WTF is that the methods don't go up to 40. 40 rec data's is an absolute minimum for me.

  • Markp (cs)

    Time to switch to Java 1.5+? Unfortunately switching these to varargs wouldn't maintain binary compatibility with any compiled code already calling them.

  • Max Peck (cs) in reply to Markp

    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

  • Sam Sneed (unregistered)

    ...and he didn't code this via copy/paste either.

  • Oscaruzzo (unregistered)

    Throws Exception???

  • akatherder (cs) in reply to Xenon Xavior
    Xenon Xavior:
    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.

    Anyone who actually uses these functions deserves exactly what they get if there is a bug in them.

  • J (unregistered)

    Only asked for 20? Such lack of ambition, you should have gone for a much higher number.

  • toth (cs)

    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."

  • frits (cs)

    Clearly he should've used recursion.

    BTW, Where's the definition of setRecData(String[])?

  • wtf (unregistered) in reply to Max Peck
    Max Peck:
    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

    Yes, it does. This is just pathetic.

  • ImaginaryX (unregistered)

    The goggles - they do nothing.

    Clearly this guy must have been paid by the function.

    CAPTCHA : venio - Venio, Video, Vicheo

  • Victor (unregistered)

    public String[] bapp(String...strings) { return strings; }

    ?

  • Where's the Wtf? (unregistered)

    But it's OPTIMIZED!

  • Luke (unregistered)

    Do you really need a method to populate an array?

  • DeGustibusNonDisputandumEst (unregistered)

    The real wtf is java.

  • Bob (unregistered) in reply to Max Peck
    Max Peck:
    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!

    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.

  • charriu (unregistered) in reply to Luke

    No, you don't. Actually, he creates new arrays all over the place, so...

  • Arnold (unregistered)

    If you ever see him walking around with an axe, run!

  • tom103 (unregistered)

    Wait... Java doesn't have variable-length argument lists ?

    In C# only one overload would have been needed:

    public void setRecData(params String[] data)
    {
        ...
    }
  • Matt Westwood (unregistered) in reply to DeGustibusNonDisputandumEst
    DeGustibusNonDisputandumEst:
    The real wtf is java.

    The real WTF is using arrays in Java.

  • SmittyBoy (unregistered)

    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.

  • brazzy (cs) in reply to tom103
    tom103:
    Wait... Java doesn't have variable-length argument lists ?

    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.

  • veggen (cs) in reply to tom103
    tom103:
    Wait... Java doesn't have variable-length argument lists ?

    In C# only one overload would have been needed:

    public void setRecData(params String[] data)
    {
        ...
    }

    Of course it does. The WTF wouldn't be that bad if it didn't. ...No, wait... it would.

  • Severity One (cs) in reply to tom103
    tom103:
    Wait... Java doesn't have variable-length argument lists ?
    It does, ever since Java 5, but that's only six years old, so not everybody would have caught up with it.

    You'd do it as follows:

    public void setRecData( String ... data )
    {
        ...
    }

    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[]).

  • Disgruntled Former Employee (unregistered)

    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.

  • Anon (unregistered) in reply to SmittyBoy

    Surely you mean over 9000

  • amischiefr (cs) in reply to Bobby tables

    And the day after that Billy was given his pink slip, and there was much rejoicing.

  • TheSHEEEP (unregistered) in reply to SmittyBoy
    SmittyBoy:
    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.

    Wrong. This code piece wouldn't be able unfold its full impression if it was cut down.

  • hasse (unregistered)

    The TRWTF is Java ...

  • boog (unregistered)

    Maybe it's obvious to someone else, but why "c, m, p"?

  • LANMind (unregistered)

    And you guys laugh at VB.Net programmers?

  • BoredAtWork (unregistered) in reply to SmittyBoy
    SmittyBoy:
    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.

    Ahh, but who could have guessed our intrepid young hero would go to 30?

  • DeGustibusNonDisputandumEst (unregistered) in reply to hasse

    TRWTF is double posting

  • frits (unregistered) in reply to hasse
    hasse:
    The TRWTF is Java ...
    ORLY? <span style="color:white;">dman you askimet!</span>
  • DeaDPooL (unregistered)

    jared needs to tell that dude to java up!

  • Me (unregistered) in reply to amischiefr
    <soapbox> Exactly, someone should fire this guy immediately and threaten him with severe and lasting bodily harm if he ever touches a computer again. <p>Nothing but pitchforks and torches for people who write code like this.</p> <p>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>

  • Wo0t (unregistered) in reply to LANMind
    LANMind:
    And you guys laugh at VB.Net programmers?
    If they write crappy code, yes. We actually laugh at crappy programmers no matter what language they happen to be using at the time.

    There, does that make you feel better?

  • frits (unregistered) in reply to Me
    Me:
    <soapbox> Exactly, someone should fire this guy immediately and threaten him with severe and lasting bodily harm if he ever touches a computer again. <p>Nothing but pitchforks and torches for people who write code like this.</p> <p>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>
    No, he should be sent to prison, since that is the place where rehabilitation occurs.

  • Zapp Brannigan (unregistered)

    Mine goes to 11.

  • snoofle (cs) in reply to Xenon Xavior
    Xenon Xavior:
    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.
    You, Sir, are pure Evil!

    bows

  • LANMind (unregistered) in reply to Wo0t
    Wo0t:
    LANMind:
    And you guys laugh at VB.Net programmers?
    If they write crappy code, yes. We actually laugh at crappy programmers no matter what language they happen to be using at the time.

    There, does that make you feel better?

    Not unless it sparks another holy war...

  • Aasi (unregistered)

    How about asking him to make test cases for these functions. At least we would see how easily these "helper" functions are used.

  • You Jackwagon (unregistered) in reply to frits
    frits:
    Clearly he should've used recursion.

    BTW, Where's the definition of setRecData(String[])?

    Clearly you don't understand recursion.

  • frits (cs) in reply to You Jackwagon

    Clearly you don't understand sarcasm.

  • Anon (unregistered) in reply to Bob
    Bob:
    Max Peck:
    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!

    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.

    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.

Leave a comment on “Overloaded Help”

Log In or post as a guest

Replying to comment #:

« Return to Article