• Linards (unregistered)

    Why am I first?

  • Little Bobby Tables (unregistered)
    protected Long getStatusCode() throws ProductCustomException{ Long statusCode = null; try{ statusCode = Long.valueOf(frist); //Why is this here?
    } catch (Exception ex) {
        throw new ProductCustomException(ProductMessages.GENERIC_PRODUCT_MESSAGES, ex);
    }
    return "drat";
    

    }

  • RLB (unregistered)

    I'm with the comment. Why is this a problem? Why try? Do 1, or do 0. There is no try.

  • GreetingsFromGermany (unregistered)

    I just had to mention that "Oma" is German (and Dutch) for "grandmother". It made me laugh to think of my grandma afflicted by code WTFs. She has enough trouble with technology already!

  • David Green (unregistered)

    I bet the tab/spacing discrepancy is based on the copy/paste from Stack Overflow.

  • Zach (unregistered)

    TRWTF is why in the first code block does the comment have a border? It's making the code look messed up

  • (nodebb)

    TRWTF is why statusCode is always set to 1. If all status codes are equal, what do they track?

  • Brian Boorman (google) in reply to Bananafish

    Because it was a stub for some functionality that was never implemented - because management said "It works. Ship it!"

  • ooOOooGa (unregistered)

    'Why is this here?' seems like the wrong question to ask. That answer is easy. That line is there so that statusCode does not stay null.

    Other questions that I have:

    • Why does this function always return a status code of 1?
    • Why does the 1 need to be of type Long?
    • I'm not overly fluent in C#, but I expect that there is a way of writing a literal Long 1 rather than using the number parsing functions each time. Why not use that?
    • Is there any scenario that is going to cause this function to return null instead of throwing an exception?
    • Is there any scenario that is going to cause this function to throw an exception?
    • Is there any reason to ever use this function? Considering that all it ever does is return 1 as type Long.
  • ooOOooGa (unregistered)

    Wait, this is Java. I know that one.

    protected Long getStatusCode() { return 1L; }

  • (nodebb)

    So the right comment would be:

    Why is this function here?

  • robby the robot (unregistered)

    Looks like a test or god mode that you activate by changing the 1 to something else.

    And who cares about spaces v tabs?

  • kiwi (unregistered) in reply to robby the robot

    Let the holy wars begin.........

  • Darkenon (unregistered) in reply to Zach

    This must be some weird rendering bug on Chrome, all of the comments have borders, but it's only this one that looks weird.

  • Jarfil (unregistered)

    In case of large values of 1...

  • sizer99 (google) in reply to robby the robot

    Use spaces, use tabs, whatever you want. But mixing spaces and tabs is always The Real WTF and your instant clue you're dealing with a brillant programmer.

  • Chris (unregistered) in reply to ooOOooGa

    Long.valueOf(1) doesn't parse anything (as it would if you passed it a string), but rather boxes it into a Long instance (an object). Basically the same as new Long(1), but supposedly more efficient in cases such as this where the same values are often used (see https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html#valueOf-long-). This is different from 1L, which is a primitive number type.

    And no, it never raises an exception of any kind nor can it ever return null. Unless there is something messing with your JVM / memory (damn gamma rays!).

  • Mischa (unregistered)

    Returning a constant result makes perfect sense if it is an implementation of an interface. Also, this might be the origin the WTF code: the implementor copied from another implementation without removing the try catch block.

  • Murray (unregistered) in reply to GreetingsFromGermany

    Thought about this, too. But then, my kids' grandmother is a programmer. Also apparently there was "Grandma COBOL".

  • Little Bobby Tables (unregistered) in reply to sizer99

    Had a colleague once who used to get me to help her debug her javascript errors. 9 times out of 10 (possible exaggeration for rhetorical flourish) it was caused by unbalanced braces and/or brackets.

    My first advice to her was always "Format your code neatly." This is before resolving the tabs / spaces question -- this is to get the lines of the code to line up properly in the first place.

    Once she had indented consistently, and got things to line up in a neat little pattern, the missing and unbalanced braces and brackets were usually immediately apparent.

    The real WTF was that she never seemed to learn this lesson.

  • robby the robot (unregistered) in reply to sizer99

    Format it however you want when you're writing it, then run the code through a styler that is configured to the in-house standard. Similarly when looking at existing code reformat it to start with.

  • eric bloedow (unregistered)

    "the indenting is provided via a mix of spaces and tabs"...reminds me of a story about someone who didn't know how to do "carriage returns", and added spaces to the END of every line, trying to make them match up on the screen!

  • Herr Otto Flick (unregistered) in reply to Little Bobby Tables

    Or in vim, 1GVG=

  • Fernando (unregistered) in reply to sizer99

    Or maybe an experienced programmer. One who started out with real computer terminals where a TAB always advanced to the next column of 8, connected to time-sharing systems where disk space was at a premium and wasted by lots of spaces.

  • ZeroBee1 (unregistered) in reply to Darkenon

    It looks like whatever lib TDWTF uses to display the code blocks wrap parts of the code with span's to allow parts of it to be styled (eg the blue colour of the number literal and the red of the method name). A span with the class comment wraps the comment text, and it looks like this conflicts with the sites own stylesheet at https://thedailywtf.com/Content/Css/main.css which defines it's own styles for the .comment selector, which is used for these comments.

  • smf (unregistered)

    I think the answer to "why this is here"? Is that the developer never finished the code, probably got distracted by the phone ringing or going home time.

  • Tabs & Spaces (unregistered)

    "what's not immediately clear here is that the indenting is provided via a mix of spaces and tabs."

    Sad people don't seem to understand what fixed-width fonts are, or how to use a CLI editor (this is why we have things like Yaml).

Leave a comment on “Why Is This Here?”

Log In or post as a guest

Replying to comment #:

« Return to Article