• (cs)

    This is what happens when you don't have proper callback function pointers.

  • (cs)

    This is what happens when you develop the Golden Hammer.

  • Andrew (unregistered)

    Looks like UI code - in which case, it's not so bad. It's a bold attempt to try to get Java to behave at least somewhat nicely. henke37 has the right answer.

    Not to turn this into a language war, but C# gets it right with delegates and events.

  • Mark (unregistered)

    The real WTF is that there is no real WTF with this post.

  • JonF (unregistered)

    implements Listener?

  • (cs)

    The fake WTF is that it's not using VB.

  • dude (unregistered)

    The non-sequiter WTF is a dolphin eating cake.

  • sweet (unregistered) in reply to dude

    The cake is a lie.

  • (cs)

    The surreal WTF is a bathtub full of power tools painted orange.

  • dsp (unregistered)

    The REAL WTF here is that the title of the WTF reads "Classic WTF: Implements ISwissArmyKnife". I see two problems with this title.

    First: You've got a syntax error here. "Implements" should be "implements" (no capital i). Second: Prepending an 'I' or any other prefix to indicate a type to a class name or interface is considered bad practice in Java and violates the Sun Java naming conventions.

    So the real title should be "Classic WTF: implements SwissArmyKnife".

  • dsp (unregistered)

    The REAL WTF here is that the title of the WTF reads "Classic WTF: Implements ISwissArmyKnife". I see two problems with this title.

    First: You've got a syntax error here. "Implements" should be "implements" (no capital i). Second: Prepending an 'I' or any other prefix to indicate a type to a class name or interface is considered bad practice in Java and violates the Sun Java naming conventions.

    So the real title should be "Classic WTF: implements SwissArmyKnife".

  • (cs) in reply to Andrew
    Andrew:
    Not to turn this into a language war, but C# gets it right with delegates and events.

    The Boring WTF is that someone thinks a different language would have made a difference in the code.

  • Tigger (unregistered)

    Knives not knifes

  • (cs) in reply to dsp

    Two problems. Two identical posts. A WTF about the WTF. Makes sense to me! :)

  • Dan Krüsi (unregistered)

    I have this strong feeling that the implemented interfaces all look something like this:

    public interface MessageListener { public void messageRecieved(Message msg); }

  • Rob (unregistered) in reply to henke37

    ...

    How would that make it any better? The problem is clearly that this object has far too much responsibility than it should. 'Proper callback function pointers' won't fix that - only better design will fix that.

  • (cs) in reply to sweet
    sweet:
    The cake is a lie.
    And there is no quack.
  • James (unregistered)

    Still not seeing the problem -- like another poster said, sounds like UI code. You've got your main window in your application waiting for input, like a secretary with 14 phones at her desk. Maybe the design should be split up with multiple secretaries answering smaller groups of phones, but maybe the phones don't ring that often and the 14-line receptionist is the best answer to the problem. Without a bit more body in the "//snip", I can't accept this one as a WTF (yet).

  • A raptor (unregistered)

    All these listeners and nobody's going to make a joke about women?

    Also, the real WTF is that global warming will kill us all and nobody's doing anything about it.

  • (cs) in reply to James
    James:
    Still not seeing the problem -- like another poster said, sounds like UI code. You've got your main window in your application waiting for input, like a secretary with 14 phones at her desk. Maybe the design should be split up with multiple secretaries answering smaller groups of phones, but maybe the phones don't ring that often and the 14-line receptionist is the best answer to the problem. Without a bit more body in the "//snip", I can't accept this one as a WTF (yet).
    The problem isn't that the developer wrote it this way, its that Java requires it to be written this way. And the fact that people seem to think there couldn't be a better way is one of the best arguments that closures need to be implemented in Java.
  • G (unregistered)

    looks like a very good companion - listens alot and talks nothing

  • Franz Kafka (unregistered) in reply to Rob
    Rob:
    ...

    How would that make it any better? The problem is clearly that this object has far too much responsibility than it should. 'Proper callback function pointers' won't fix that - only better design will fix that.

    My minimal fix would involve a bunch of private classes that implement various interfaces and talk to the object in question. But yeah, you gotta split that up a bit.

  • (cs) in reply to nwbrown

    neither can Java afford the complexity costs of closures currently ... nor forces Java you to program like this.

  • Fatal_Exception (unregistered)

    Holy responsibility, Batman!

  • Mario (unregistered) in reply to dsp
    dsp:
    The REAL WTF here is that the title of the WTF reads "Classic WTF: Implements ISwissArmyKnife". I see two problems with this title.

    //snip

    So the real title should be "Classic WTF: implements SwissArmyKnife".

    I think the title is in VB.Net ...
  • Kerin (unregistered) in reply to henke37

    The REAL wtf is that I'm pretty sure at least a few of you miserable jerks has been with a woman.

  • BillyBob (unregistered) in reply to A raptor
    A raptor:
    Also, the real WTF is that global warming will kill us all and nobody's doing anything about it.

    What's the problem? We're all going to die anyway...

  • BillyBob (unregistered) in reply to A raptor
    A raptor:
    Also, the real WTF is that global warming will kill us all and nobody's doing anything about it.

    What's the problem? We're all going to die anyway...

  • (cs)

    No WTF: radio!

  • Neomojo (unregistered) in reply to Quicksilver
    Quicksilver:
    neither can Java afford the complexity costs of closures currently ... nor forces Java you to program like this.

    (emphasis added) WTF?

  • A (unregistered)

    Am I the only one here who thinks that this looks like Mediator Pattern. Nothing in GoF can ever be a WTF.

  • Patrick (unregistered) in reply to Quicksilver
    Quicksilver:
    This is what happens when you develop the Golden Hammer.

    I used that as an attempt to provide some constructive criticism of a coworker's class, and he took it as a compliment. I said to him, "That class does quite alot, isn' that a little bit of a golden hammer?" He goes, "Yeah, isn't it neat!"

  • john (unregistered) in reply to Quicksilver
    Quicksilver:
    nor forces Java you to program like this.

    ...in Soviet Russia Java forces YOU to program!!

  • ounos (unregistered)

    The (small) WTF is that the coder seems to feel obliged to pass "this" wherever a callback is required. Could use anonymous class instances that call back into private methods, not exposed on the api.

Leave a comment on “Classic WTF: Implements ISwissArmyKnife”

Log In or post as a guest

Replying to comment #168654:

« Return to Article