Favorite Code Mangles



  • Is it cool to use a/this thread to post WTFs as I catch them in my day-to-day work instead of starting a new thread everytime I see something new? i.e., a long-running thread to chronicle my findings?



  • No.



  •  It depends.   What have you got?



  •  What a fantastic thread! This is getting off to a great start!



  • @zelmak said:

    Is it cool to use a/this thread to post WTFs as I catch them in my day-to-day work instead of starting a new thread everytime I see something new? i.e., a long-running thread to chronicle my findings?

    Please send me the codes.

     Thank You.

     



  • @zelmak said:

    Is it cool to use a/this thread to post WTFs as I catch them in my day-to-day work instead of starting a new thread everytime I see something new? i.e., a long-running thread to chronicle my findings?
     

    If you include actual WTFs then it wouldn't be that different from others where there are updates of "hey look what else I found" but currently...



  • @zelmak said:

    Is it cool to use a/this thread to post WTFs as I catch them in my day-to-day work instead of starting a new thread everytime I see something new? i.e., a long-running thread to chronicle my findings?

    It would be cool, if you had actually posted any WTFs.



  • Oh, I have a great idea! How about you post some WTF code in this thread, that would be AWESOME!



  •  @zelmak said:

    Is it cool to use a/this thread to post WTFs as I catch them in my day-to-day work instead of starting a new thread everytime I see something new? i.e., a long-running thread to chronicle my findings?

    If you have that many, you should cherry-pick the really good ones.

    Otherwise you should probably create a blog.

     



  • @zelmak said:

    Is it cool to use a/this thread to post WTFs as I catch them in my day-to-day work instead of starting a new thread everytime I see something new? i.e., a long-running thread to chronicle my findings?

    It's cool if and only if you actually do post some WTFs. So far, you haven't. Which is a shame.



  • The answer is a definite "maybe".



  • @badcaseofspace said:

    The answer is a definite "maybe".
     

    Now, let's not be too hasty withour snap judgements...



  • Soooo hi! This is my new blog. I will post some really cool things here in a while. Heeeeh. Love you all. MUCK



  • Zelmak sounds like a bad Doctor Who villain.

    He probably posted that before looking at the code base, and now he's like "oh shit I can't back that up!" frantically trying to find WTFs.



  • @blakeyrat said:

    Zelmak sounds like a bad Doctor Who villain.

    He probably posted that before looking at the code base, and now he's like "oh shit I can't back that up!" frantically trying to find WTFs.

     

     

    Will you quit with the Doctor Who references, it's quickly becoming gay and repetitive.  I would go so far as to say almost as much as xkcd links.

     



  • @blakeyrat said:

    Zelmak sounds like a bad Doctor Who villain.

    He probably posted that before looking at the code base, and now he's like "oh shit I can't back that up!" frantically trying to find WTFs.

    Agreed. He's probably one of those hipster, Gentoo-linux, Ruby-on-Rails posers who just got a job as a legitimate programmer, thought it would be angsty/counterculture/cool to post shit on TDWTF side bar forums, but now realizes how terrible he is at coding as he's crawling through the repository.



  • @Helix said:

    Will you quit with the Doctor Who references, it's quickly becoming gay and repetitive.  I would go so far as to say almost as much as xkcd links.

    I'm pretty sure that's the first time I've ever made a Doctor Who reference ever.



  • @blakeyrat said:

    @Helix said:
    Will you quit with the Doctor Who references, it's quickly becoming gay and repetitive.  I would go so far as to say almost as much as xkcd links.

    I'm pretty sure that's the first time I've ever made a Doctor Who reference ever.

    Apparently Helix is super impatient, and once is enough for him.



  • @blakeyrat said:

    @Helix said:
    Will you quit with the Doctor Who references, it's quickly becoming gay and repetitive.  I would go so far as to say almost as much as xkcd links.

    I'm pretty sure that's the first time I've ever made a Doctor Who reference ever.

     

     Here is the first one that i saw:

    http://forums.thedailywtf.com/forums/p/24586/258588.aspx#258588

    And here is a second:

    @blakeyrat said:
    Zelmak sounds like a bad Doctor Who villain.

    And finally the third time i have seen you reference 'Doctor Who':

    @blakeyrat said:

    I'm pretty sure that's the first time I've ever made a Doctor Who
    reference ever.



  • I recall you made a Who reference in one of those lamey flamey threads about metric; something about Donna running a half a mile away during that one episode with the spacey time-shifty alien bug thingy on her back. I thought that was a pretty good episode. If anything, you don't make ENOUGH Doctor Who references. Also, you should juxtapose them with Blake's 7 references. But just never the last episode BECAUSE I NEVER WANT TO THINK OF IT AGAIN. :'(



  • @Helix said:

    Here is the first one that i saw:

    http://forums.thedailywtf.com/forums/p/24586/258588.aspx#258588

    Ok, yeah, that was a reference to Doctor Who, but it was pointing out evidence for an argument I was making, not a cheap joke. So totally different. And British people still say "miles" all the fucking time while lecturing us Americans on how they've "gone metric", fucking hypocrites.

    @Helix said:

    @blakeyrat said:
    I'm pretty sure that's the first time I've ever made a Doctor Who
    reference ever.

    That is a META-reference. Totally doesn't count.

    @Xyro said:

    Also, you should juxtapose them with Blake's 7 references. But just never the last episode BECAUSE I NEVER WANT TO THINK OF IT AGAIN. :'(

    Avon lives.

    He's the most magnificent of magnificent bastards. There's no way he died. None. Unpossible.



  • o.O ... asking for permission and I got 20 replies? Well, okay ...


    if (((float) ((int) (validCount / 10))) == ((float) validCount / 10.0)) {
      output.append(Constants.CARRIAGE_RETURN);
    }

    yay for code readability ...

    yay for possibly not working (but probably will) due to floating point representation of integer values and their equality ...

    yay for not knowing the modulus/remainder-of operator ...

    has anyone every complained about this forum's usability? :evilgrin:



  • @zelmak said:

    o.O ... asking for permission and I got 20 replies? Well, okay ...


    if (((float) ((int) (validCount / 10))) == ((float) validCount / 10.0)) {
      output.append(Constants.CARRIAGE_RETURN);
    }

     

    that is actually a good one.... what type is validcount?

     



  • So, there's this config file, with field names and types in it ...

    And, a (what someone might call) "generic" 'data holding object' with getters and setters

      Method method = object.getClass().getMethod().(new String("get" + fieldname), (Class[]) null); 
      if ( fieldname.indexOf("BigInteger") >= 0) {
        BigDecimal tmpBigDecimal = (BigDecimal) method.invoke(object, (Object[]) null);
    
    if ( tmpBigDecimal.scale() > 0 ) {
      rtn = String.valueOf( tmpBigDecimal.floatValue() );
    }
    else {
      rtn = String.valueOf( tmpBigDecimal.intValue() ); 
    } 
    

    else {
    rtn = String.valueOf ( method.invoke (object, (Object[]) null );
    }

    All this to simulate/emulate:

    map.get(fieldName);

     


  • Discourse touched me in a no-no place

    @zelmak said:

    has anyone every complained about this forum's usability?
    Now you come to mention it, no. They haven't. No-one's ever mentioned the double delete, or the crap that results from copy/pasting a reply composed in Word. Why do you ask?@zelmak said:
    :evilgrin:
    WTF is that?


  • ♿ (Parody)

    @zelmak said:

    o.O ... asking for permission and I got 20 replies?

    As soon as you start a thread, it is not your own.



  • public int compareResult(Object o) {
    
      // ... do stuff to calculate return value ...
    
      if (rtn != 0) {
        return rtn;
      }
    
      return rtn;
    
    }

    or, better yet, one of my favorites:

    public String calcStringValue(String inputString) {
      String retValue = // do something with inputString to calculate the return value
    

    if (retValue == null) {
    return null;
    }

    return retValue;
    }



  • Not bad... I've seen surprisingly similar style code where I worked.  Here is a snippet:

    [code]Session["SomeSessionKey"] = (MyObjectType)null;[/code]

    Give me that fucking keyboard!

    As a side note, I didn't know you can have null of type MyObjectType...



  • @boomzilla said:

    @zelmak said:
    o.O ... asking for permission and I got 20 replies?

    As soon as you start a thread, it is not your own.

    But seriously, next time post a WTF. This is "sidebar WTF" not "ask permission to maybe start a thread perhaps where you might perhaps sometimes post WTFs I guess maybe if you're lucky perhaps."



  • Sadly, most of the BIG WTFs I run into are the architectural ones where, without having the whole kit-and-kaboodle in front of you, it is difficult to see the WTFness.

    This however, isn't one of them... Found in a script on a UNIX system:

    <COMMAND-THAT-CREATES-OUTPUT> | nawk "BEGIN {x = 0}; {x++; if (x==1) print $0}"

    I don't know of a modern, mainstream UNIX (or UNIX-like) system that doesn't have 'head' or 'tail'...


  • ♿ (Parody)

    @zelmak said:

    public int compareResult(Object o) {

    // ... do stuff to calculate return value ...

    if (rtn != 0) {
    return rtn;
    }

    return rtn;

    }

    or, better yet, one of my favorites:

    public String calcStringValue(String inputString) {
      String retValue = // do something with inputString to calculate the return value
    

    if (retValue == null) {
    return null;
    }

    return retValue;
    }

    These look like standard poor man's conditional breakpoints.



  • Most of the WTFs that I run into, are major architectural snafus that are hard to explain without having the whole thing in front of you and tracing through the WTF-ery.

    This, however, isn't one of them. A local UNIX script, still in use:

    <command-that-creates-output> | nawk "BEGIN {x = 0}; {x++; if (x==1) print $0}"

    I don't remember the last time I saw relatively modern, mainstream UNIX without the 'head' or 'tail' commands/programs...

    Edit: Err, the original didn't show up ... and when it did, it had entity problems ... and now I can see it ... and I'm sad.



  •  Ah you are right, a thread full of TRWTF



  • you know, without looking I'd have to assume int, but it WOULD be pretty WTFy to have a counter-type use a float ...

    ah, found it ... thank goodness it is, in fact, an int.



  • Much of the code I maintain is legacy ... not in the 'old language' or 'old platorm' sense of the phrase. Just 'old' ... Java written by C programmers in the 1998-2002 timeframe.

    The following is circa 2002 according to CVS check-in date:

    DecimalFormat twoDigits = new DecimalFormat("00");
    

    StringBuffer filename = new StringBuffer();

    Calendar calHolder = Calendar.getInstance(); Date dateHolder = new java.util.Date();

    calHolder.setTime(filenameHolder);

    int intHolder = calHolder.get( Calendar.YEAR );

    if (intHolder > 1900) {
    intHolder = intHolder - 1900;
    }

    if (intHolder > 100) {
    intHolder = intHolder - 100;
    }

    filename.append(String.valueOf(twoDigits.format(intHolder)));
    intHolder = calHolder.get( Calendar.MONTH );
    intHolder++;
    filename.append(String.valueOf(twoDigits.format(intHolder)));
    filename.append(String.valueOf(twoDigits.format(calHolder.get( Calendar.DATE )));
    filename.append(String.valueOf(twoDigits.format(calHolder.get( Calendar.HOUR_OF_DAY )));
    filename.append(String.valueOf(twoDigits.format(calHolder.get( Calendar.MINUTE )));
    filename.append(String.valueOf(twoDigits.format(calHolder.get( Calendar.SECOND )));

    Note: SimpleDateFormat predates this code. Personnaly, I feel that the Java Date library (or whatever it is descended from) needs to be taken out back and shot. Seriously? Everything is zero-based, except the date?


  • 🚽 Regular

     For fuck's sake get a new job before this one kills you!



  • @RHuckster said:

     For fuck's sake get a new job before this one kills you!
    Why? He seems content spending his time posting ancient WTF code...



  • @blakeyrat said:

    This is "sidebar WTF" not "ask permission to maybe start a thread perhaps where you might perhaps sometimes post WTFs I guess maybe if you're lucky perhaps."
    Yes.  I think that's called Stack Exchange.

     



  • Some FORTRAN I found once:

    IF (DISTRICT .LT. 1 .AND. DISTRICT .GT. 3) THEN

    WRITE (*, *) ' District out of range'

    GOTO 999

    END IF



  • @boomzilla said:

    @zelmak said:
    public int compareResult(Object o) {

    // ... do stuff to calculate return value ...

    if (rtn != 0) {
    return rtn;
    }

    return rtn;

    }

    or, better yet, one of my favorites:

    public String calcStringValue(String inputString) {
      String retValue = // do something with inputString to calculate the return value
    

    if (retValue == null) {
    return null;
    }

    return retValue;
    }

    These look like standard poor man's conditional breakpoints.

    Seen that sort of thing a few times in the past, specially when code has been written fast and furiously. Written some stuff like that myself. When I find stuff like this, I just chuckle and rewrite it.



  • @blakeyrat said:

    @Helix said:
    Here is the first one that i saw:

    http://forums.thedailywtf.com/forums/p/24586/258588.aspx#258588

    Ok, yeah, that was a reference to Doctor Who, but it was pointing out evidence for an argument I was making, not a cheap joke. So totally different. And British people still say "miles" all the fucking time while lecturing us Americans on how they've "gone metric", fucking hypocrites.

    @Helix said:

    @blakeyrat said:
    I'm pretty sure that's the first time I've ever made a Doctor Who
    reference ever.

    That is a META-reference. Totally doesn't count.

    @Xyro said:

    Also, you should juxtapose them with Blake's 7 references. But just never the last episode BECAUSE I NEVER WANT TO THINK OF IT AGAIN. :'(

    Avon lives.

    He's the most magnificent of magnificent bastards. There's no way he died. None. Unpossible.

    You're right, he didn't die - I know this, because several years later (1998 or 1999, I believe) I caught him playing Captain Vimes in a performance of Guards! Guards! at the Reading Hexagon. But Granny Weatherwax was sitting in front of me and it was difficult to see past her hat.



  • @Matt Westwood said:

    Some FORTRAN I found once:

    IF (DISTRICT .LT. 1 .AND. DISTRICT .GT. 3) THEN

    WRITE (*, *) ' District out of range'

    GOTO 999

    END IF

    I am a math major about to start my diploma thesis and I think I can safely say that something smells fishy about this: In the write command, there's an emoticon in between the function name and the argument, and it looks shocked. I am pretty sure it should look happy, because writing something to the screen is a joyful event.



  • @Matt Westwood said:

    You're right, he didn't die - I know this, because several years later (1998 or 1999, I believe) I caught him playing Captain Vimes in a performance of Guards! Guards! at the Reading Hexagon. But Granny Weatherwax was sitting in front of me and it was difficult to see past her hat.

    I prefer to purposefully delude myself without entering an imaginary land of spells and fairies.



  • @blakeyrat said:

    @Helix said:
    Here is the first one that i saw:

    http://forums.thedailywtf.com/forums/p/24586/258588.aspx#258588

    Ok, yeah, that was a reference to Doctor Who, but it was pointing out evidence for an argument I was making, not a cheap joke. So totally different. And British people still say "miles" all the fucking time while lecturing us Americans on how they've "gone metric", fucking hypocrites.

    @Helix said:

    @blakeyrat said:
    I'm pretty sure that's the first time I've ever made a Doctor Who
    reference ever.

    That is a META-reference. Totally doesn't count.

    @Xyro said:

    Also, you should juxtapose them with Blake's 7 references. But just never the last episode BECAUSE I NEVER WANT TO THINK OF IT AGAIN. :'(

    Avon lives.

    He's the most magnificent of magnificent bastards. There's no way he died. None. Unpossible.

    Of course he didn't die, he just ducked and they all shot each other!



  • @zelmak said:

    The following is circa 2002 according to CVS check-in date:

    DecimalFormat twoDigits = new DecimalFormat("00");
    

    StringBuffer filename = new StringBuffer();

    Calendar calHolder = Calendar.getInstance(); Date dateHolder = new java.util.Date();

    calHolder.setTime(filenameHolder);

    int intHolder = calHolder.get( Calendar.YEAR );

    if (intHolder > 1900) {
    intHolder = intHolder - 1900;
    }

    if (intHolder > 100) {
    intHolder = intHolder - 100;
    }

    filename.append(String.valueOf(twoDigits.format(intHolder)));
    intHolder = calHolder.get( Calendar.MONTH );
    intHolder++;
    filename.append(String.valueOf(twoDigits.format(intHolder)));
    filename.append(String.valueOf(twoDigits.format(calHolder.get( Calendar.DATE )));
    filename.append(String.valueOf(twoDigits.format(calHolder.get( Calendar.HOUR_OF_DAY )));
    filename.append(String.valueOf(twoDigits.format(calHolder.get( Calendar.MINUTE )));
    filename.append(String.valueOf(twoDigits.format(calHolder.get( Calendar.SECOND )));

    Looks like the y2k compatibility project over-ran by a bit there....

     



  • @zelmak said:

    Is it cool to use a/this thread to post WTFs as I catch them in my day-to-day work instead of starting a new thread everytime I see something new? i.e., a long-running thread to chronicle my findings?

    NO... You should post them here: http://forums.thedailywtf.com/forums/t/24690.aspx



  • @DaveK said:

    @blakeyrat said:
    @Xyro said:
    Also, you should juxtapose them with Blake's 7 references. But just never the last episode BECAUSE I NEVER WANT TO THINK OF IT AGAIN. :'(

    Avon lives.

    He's the most magnificent of magnificent bastards. There's no way he died. None. Unpossible.

    Of course he didn't die, he just ducked and they all shot each other!
    Yes :D that is what happened :D they all shot each other ... multiple times ... :| with the guns going off for like a minute ... all constantly shooting each other :( ... with Avon ... ducking.. ... :'(


  • @Xyro said:

    Yes :D that is what happened :D they all shot each other ... multiple times ... :| with the guns going off for like a minute ... all constantly shooting each other :( ... with Avon ... ducking.. ... :'(

    Best character ever.



  • @Xyro said:

    with the guns going off for like a minute ... all constantly shooting each other
     

    I'm reminded of Shoot Em Up, a fun and amusing movie about bullets and unlikely heroics. Recommended.



  • I've lost control ... oh, wait ... I never had it to begin with.

    @TheCPUWizard said:

    NO... You should post them here: http://forums.thedailywtf.com/forums/t/24690.aspx

    StackOverflowException occurred in CommunityServer.handleThat(). Abort, retry, File Not Found (y/n/q)?


Log in to reply