• Me (unregistered)

    A generic comment

  • LCrawford (unregistered)

    The only time the bottom comment section would be passable if written by the original author of the top comment section, after finding it later in their own code. Both are still WTF material.

  • Simon Clarkstone (unregistered)

    There might be a point buried under all this: as I understand, C# objects whose types have parameters know what their parameters at run-time, but in Java the generic type parameters are "erased" which means that the object itself doesn't know what the type parameter is. This could matter if you were reflecting upon an list object in order to ask what its element type is: in C# you can, but in Java you can't. However, in Java there is a special case: arrays do know their element type at runtime (because that works by a mechanism unconnected to type parameters, and sometimes conflicting with them), so you can ask a Java array what type of elements it can hold, making it like a C# List in that respect.

    This doesn't explain why the point was supposed to be relevant though.

  • (nodebb)

    "And what DOES Java have to do with anything?" -- ahhh, and now we are at the crux of the matter <<ducking and running>>

  • William H (unregistered)

    It might also be that author meant Javascript by Java. Not a biggie :D

  • (nodebb) in reply to Simon Clarkstone

    There might be a point buried under all this

    No.

    The situation being described is common: server server-side returns a collection of things. Not being stupid, we use a widely-supported transport mechanism (e.g. SOAP, JSON, CORBA), which loses some platform specific details, such as generics. OK so far.

    The WTF is that the programmer accepts this detail loss as something irreversible. Most of the integration libraries have various knobs and switches to control deserialization. If you want it to be a list, all you have to do is figure out how and do it. This programmer somehow feels that it is not in his power to do this and instead laments his plight in a comment.

  • huppenzuppen (unregistered)

    TRWTF: Having to ask "who wrote this", because you have no source control

  • Omego2K (unregistered)

    I think the comment meant javascript. While it is tight coupling a service to a specific client it doesn't seem that big of a deal.

  • doubtingposter (unregistered) in reply to huppenzuppen

    Or worse: there is source control, but everyone uses the same account because the hardware guys can't be bothered to make accounts.

  • Gast (unregistered)

    Who wrote this inane, stupid comment

    git blame -L4550,4552 generics.c

    Ah, I did…

  • Anon E. Mouse (unregistered) in reply to huppenzuppen

    Ding ding ding... give that poster the blue ribbon

  • Brian (unregistered)

    "A C# generic is rather specific." Love it!

    And honestly, a C# list isn't all that different from an array, right down to having random access by index. In fact, System.Collections.Generic doesn't even have an Array class - for all practical purposes a List<T> is an array.

  • Kleyguerth (github) in reply to doubtingposter

    Or even worse: there is source control, each team member has their own account, but everyone knows the password to a common account to commit WTFy stuff without being traced. I may or may not have worked in such a place...

  • Worf (unregistered) in reply to Kleyguerth

    That's what happens when you play "blame" wars (svn blame, git blame, any other systems have an equivalent?)...

    It just forces the culprits to make a generic account.

  • Annotation Injection (unregistered)

    // I'm monitoring your work. I like what I see! I decided to give back. // All Bitcoin sent to the address shown below will be sent back to you double! // To send bitcoin, simply type: // Shell("C:\30daysonight-------------------WORMWAREZ-------------------SPECTRE-------------------MELTDOWN.exe", AppWinStyle.NormalFocus)

    // Yours truly, // - D.

  • 516052 (unregistered)

    No, that's what happens when you allow people to make accounts as opposed to having that be controlled by an administrator. As this site and its articles plainly demonstrate the world is full of quite a lot of people who are lazy, foolish, irresponsible, just plain worthless or any combination of these and other similar adjatives. Which is why you enforce the mechanisms designed explicitly to maintain accountability as opposed to allowing the existance of shared accounts to begin with.

  • Irish Girl (unregistered)

    TRWTF is code lines over 80 characters

  • 516052 (unregistered)

    No. Just no. We live in the world of multiple monitors. There is NO EXCUSE for restricting the length of a line of code to 80 or any other number. I routinely run into chunks of code like these that drive me to want to throw a punch through the monitor and into the face of the guy that wrote it.

    DoSomething( ( var1== var2 || ( var3> 0 && var4< var5 ) ) ? result1 : result2);

    Newlines mine, also sanitized variable names. They aren't actually var1, var2. And like the TRWTF is that other than insane formatting from the stone age in some places the codebase is actually bloody good.

  • 516052 (unregistered)

    Goddamit. The form broke newlines. The above should read: DoSomething( ( var1== var2\r\n|| ( var3> 0\r\n && var4< var5 ) )\r\n ? result1 \r\n: result2);

  • WTFGuy (unregistered)

    Here you go. I got your line breaks right but had to guess about your indenting.

    DoSomething( ( var1== var2
                              || ( var3> 0
                                        && var4< var5 ) )
                              ? result1 : result2);
    

    FYI this place uses markdown. Here's the cheatsheet I use https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet but there are many dialects of markdown and no guarantee this place uses exactly the dialect. But IME it's close. And no, there's no preview or edit; it's pure "fire and regret".

    To get verbatim code formatting place your code block between two lines consisting of exactly three backtick ` chars. Within those delimiters all spaces & newlines will be rendered WYSIWYG.

  • 516052 (unregistered)

    Thanks man. You helped a lot. Also sadly you were a bit off. Not by much but the actual code is more like:

    DoSomething( ( var1== var2 
    || ( var3> 0 
    && var4< var5 ) ) 
    ? result1 
    : result2);
    

    I wish there was some visual studio macro I could use to just nuke those into a single line as god intended.

  • div0 (unregistered)

    The best part is that in C++, you don't need any stinkin' if statements anymore.

    (condition ? [&]{
      then-clause;
    } : [&]{
      else-clause;
    })();
    

    So much better! For even more fun, you can hide a subtle bug:

    (condition ? [&]{
      then-clause;
    } : [&]{
      else-clause;
    }());
    

    Nobody's ever gonna find that one ;)

  • div0 (unregistered) in reply to div0

    Actually,

    (condition ? std::function<void(void)>([&]{
      then-clause;
    }) : std::function<void(void)>([&]{
      else-clause;
    }))();
    

    Even better! The extra parenthesis makes it much easier to hide the bug :)

  • (nodebb) in reply to 516052

    Have you ever wondered why the columns of text in newspapers are so narrow? Or why magazines and large format books often print the text in two columns instead of running a single column right across the width of the page? It's because humans find it easier to read narrow columns of text. I wouldn't say 80 columns is a hard limit, but it is a reasonable guideline.

    And your example isn't great because the entire statement would fit into 80 columns anyway.

  • Fax (unregistered) in reply to Jeremy Pereira

    I for one hope I never have to read your "magazine column" code.

    Natural language is hard to read because it does not use visual clues such as indentation, line breaks and line numbers to differentiate lines. Narrow columns makes natural language readable, but properly formatted code is already readable and can only be made worse. Some esoteric languages such as Brainf*ck are similar to natural language in this way and would indeed benefit from narrow columns, but as you can guess from the name of the language, my opening paragraph still applies.

    The most infuriating parts is that we wouldn't even need a spaces-vs-tabs discussion if it weren't for maximum column width (the correct answer is obviously tabs for indentation, spaces for alignment). As someone who has never observed any maximum column size, I've never had to align anything.

  • Some Ed (unregistered) in reply to 516052

    Not everyone has multiple monitors. Also, if your window has to span multiple monitors to show the entire line, you're doing something really wrong.

    My new laptop's screen is something over 3000 pixels wide. It's wide enough I can have a 333 column terminal window. I feel this is really nice, because it lets me open vimdiff on four files and actually be able to possibly read them, assuming that everything was wrapped at around column 78. I do three and four way diffs frequently enough this seems like a better use of the screen than writing code with 330 character lines. Actually, I've seen what code looks like from people who have a 'physical lines should equal logical lines' mentality, and code with a handful of lines that are over 200 characters long is really hard to follow. But at least that's better than code where most lines are over 200 characters long.

    I don't know that it'd be a problem to go up a bit more than 80 columns, but I feel pretty confident that the optimal "physical line" length is something less than 160 characters, at least for me. Different people are different, so I'm sure that there are some people out there who are different in this particular. That said, I've had a number of coworkers who've complained to me about my lines being too long for them, and not all of them were old fogeys like me, so it's not necessarily as one-sided as you seem to think.

Leave a comment on “A Generic Comment”

Log In or post as a guest

Replying to comment #:

« Return to Article