• rd (unregistered)

    "How do you feel when you see this code on the first day of your job?" wonders Ritesh

    #define EIGHTY 256

    I would feel like I needed to correct it:

    #define EIGHTY 128 #define ONE_HUNDRED_AND_TWENTY_EIGHT 0x80

  • (cs) in reply to valetudo
    valetudo:
    C-Octothorpe:
    Bob:
    The theory that a haiku contains 17 syllables and that there's anything special about this is singularly a geek meme.

    That this is also considered a form or poetry demonstrates that most geeks should stick to what they're good at.

    For future reference, things you might find in a good haiku: . 17 morae . a seasonal reference . a juxtaposition separated with a "cut"

    Fuck off Bob And your retarded kid, Take with you

    (Yes, I know it's not haiku, but I could be arsed to write a correct one now)

    The lack of a comma on the first line disturbs me.

    The,fact,that,you,chose,to,focus,on,the,lack,of,a,comma,in,this,entire,thread,disturbs,me,.

  • (cs) in reply to PiisAWheeL

    A proper haiku Should make mention of seasons. Powdered cinnamon.

  • anonymous (unregistered) in reply to DCRoss

    In fact this is a typo...

    should be #define MIGHTY 256

  • Simon (unregistered) in reply to does not matter
    does not matter:
    The JUnit test case makes sense, at least a bit. If you start a JUnit test class without any test, it fails with an exception. But if you want to have a super class for your tests, it usually does not contain any tests, and JUnit will accuse this. Solution: Just implement such a non-sense test and be fine.

    Yes, I've seen them used occasionally when all the real tests in the file have been temporarily commented out for one reason or another. Though it makes less sense under Junit4, where you can disable tests with an @Ignore annotation.

    I've also seen it on a common parent class, where the developer hadn't realised that making the class abstract was a better way of stopping JUnit from complaining.

  • Some Java Dev (unregistered) in reply to ooblek
    ooblek:
    It actually may be a Canary test. It is an odd way of doing it (not naming it Canary test), but could serve the same purpose.

    Google TDD Canary tests...

    Actually, Google doesn't return very good results for that. So let's explain it.

    A canary test is actually an internal test of your test setup. Sometimes the setup for your unit tests can be complicated. For example, if the test you need to load a Spring application context:

    @RunWith(SpringJUnit4ClassRunner.class)
    // ApplicationContext will be loaded from "/applicationContext.xml" and "/applicationContext-test.xml"
    // in the root of the classpath
    @ContextConfiguration(locations={"/applicationContext.xml", "/applicationContext-test.xml"})
    public class MyTest {
        // class body...
    }

    You may have made a number of changes and now all the unit tests for your module are broken. So you look.. was it something you did to the model?

    However you have a simple test:

    @Test
    public void testAlwaysSucceed() {
        assertTrue(true);
    }

    This can't possibly fail right? Well, it can, but only if JUnit's setup() method throws an Exception.

    So now you know that tests are broken not because what they are testing is broken; but rather because the unit test setup is broken.

    In this case, you might go back and check if you had any recent changes to your Spring application context. If you forgot a / on tag, it could make the XML invalid, and thus your unit tests don't load.

    So, testAlwaysSucceed is your canary in the coal mine. It tells you if it's safe to rely on your tests.

  • Spoe (unregistered)
    //Clear it, or it, smack it, flip it, rub it down //(Oh nooooo...)

    // It's not too late/to whip it/whip it good.

    [image]
  • alex n (unregistered)

    the shown code has been corrected and optimized as follows,

    since it is bad form to use the same operator in the method a fix had been applied.

    private static bool InvertBool(bool org)

    {

    bool returnValue = false;
    
    
    
    if (org == true)
    
    {
    
       returnValue = false;
    
    }
    
    else if ( InvertBool(org) == false)
    
    {
    
        returnValue = true;
    
    }
    
    else
    
    {
    
        returnValue = FileNotFound;
    
    }
    
    
    
    if(returnValue == false)
    
    {
    
        return false;
    
    }
    
    else
    
    {
    
        return true;
    
    }
    
    
    
    // Default
    
    return FileNotFound;
    

    }

    I'm still waiting for the testcase to complete running It seems to be taking a while, perhaps I need a faster computer

  • qDot (unregistered)

    Fun fact: Fahrzin's entry (smack it, flip it, etc...) is from the Xport Botball Controller firmware. I should know, I wrote it, back in 2004. :D

    Had a couple of people poke me today going "HEY YOUR ON THEDAILYWTF!" Luckily, it was not the career ender that I feared. :)

  • (cs) in reply to Mr Clever Ideas
    Mr Clever Ideas:
    MrBester:
    256 is 80 in hex so there's a new WTF where a hex number is read as a decimal number and someone needed a constant
    I assume you mean duotrigesimal, not hex? :-)
    I can't help but read "dugtriogesimal".
  • (cs)

    Weird fact...

    You can delete a file BEFORE you actually read it. Of course the file must be open beforehand, but the following sequence does work:

    open (file, "rw")
    write data to file
    seek to zero on file
    delete file
    read data from file (ad nauseum, as required).
    close file (it disappears now).
    
  • SomeGuyOnTheInternet (unregistered)

    For intI = 7450 To 7450 'Now lets go and create the f*&ker ... snip... Next

    I bet you an internet that the "run once" for-next loop was so the programmer could use EXIT FOR instead of GOTO.

  • (cs) in reply to herby

    I think that might only work in unixland, which is all that really matters.

    'delete' is really 'unlink'. A file's disk space will only be recovered when there are no remaining links, and open file handles count as 'links'.

  • Cheong (unregistered)

    I'll not be surprised to see the following:

    #define HUNDRED 256

    Afterall, we all know 256 is 100 in Hex.

  • Brian (unregistered) in reply to Scott
    Scott:
    tmpnum6 = tmpnum2 + tmpnum * (tmpnum4 - tmpnum2); tmpnum7 = tmpnum3 + tmpnum * (tmpnum5 - tmpnum3); tmpnum8 = tmpnum6 + tmpnum1 * (tmpnum7 - tmpnum6);

    While the variables could certainly be named better, to me this looks like someone is trying to position something some percent of the way in a range. tmpnum's 4, 5, and 7 are the lower bounds of the range and 2, 3, and 6 are the upper bounds. tmpnum and tmpnum1 are the percentages.

    Of course, variables like 'left', 'right', and 'percent' might have been helpful.

    Yep. It's called Bilinear interpolation. It can be used to resize an image, to create Perlin noise, and for various other things.

    The way all the variables are named kinda looks like decompiler output. This might not be a WTF at all.

  • Meep (unregistered) in reply to Mathlete
    Mathlete:
    What is that rubbish? Lines of five, seven and five give a real haiku.

    An allusion to seasons, dual icons shine through true haiku, FUCK YOU WHALE!

  • (cs) in reply to Nagesh-saki
    Nagesh-saki:
    TRWTF is that someone considers Haiku so amazing as a poetic art form that we all know what it is.

    TRWTF Is somebody think all know What fuck is Hauku

  • gstein (unregistered) in reply to cappeca
    cappeca:
    The invertBool thing is the result of too many idiots enforcing OO rules that everything has to be a method, lest you have a procedural program.
    i was trying to figure out a situation in which this would be better/easier than using !bool.
  • L. (unregistered) in reply to Mathlete
    Mathlete:
    moz:
    Should let you all know That Haiku-style comments suck

    Insert missing line

    Nice :)

  • L. (unregistered) in reply to Scott_Babu
    Scott_Babu:
    tmpnum6 = tmpnum2 + tmpnum * (tmpnum4 - tmpnum2); tmpnum7 = tmpnum3 + tmpnum * (tmpnum5 - tmpnum3); tmpnum8 = tmpnum6 + tmpnum1 * (tmpnum7 - tmpnum6);

    Its part of a drum machine chang1 chang2 tata0 tata1

    feel the beat

    chang 1 tata 1 It's part of a drum machine chang 2 tata 2

    fixed :p

  • L. (unregistered) in reply to SomeGuyOnTheInternet
    SomeGuyOnTheInternet:
    For intI = 7450 To 7450 'Now lets go and create the f*&ker ... snip... Next

    I bet you an internet that the "run once" for-next loop was so the programmer could use EXIT FOR instead of GOTO.

    Define 2 5 6, Now let's create the fucker, invert boolean !

  • (cs)
    SELECT decode(authorization_kd,
     3,3,    4,3,    6,3,    7,3,    34,3,
     55,3,   57,3,   58,3,   24,4,   10,4,
     11,4,   21,4,   71,4,   36,4,   37,4,
     38,4,   13,4,   14,4,   84,4,   53,4,
     15,4,   33,4,   31,4,   32,4,   09,5,
     12,6,   52,6,   54,7,   19,8,   20,8,
     79,8,   99,8,   9) process_kd
    FROM   dossier
    WHERE  authorization_kd NOT IN (1, 30, 35, 85, 86, 87, 16, 17, 18)
    The more I look at this snippet, the more horrified I feel. Some kind of function that takes 66 parameters? A bizarre exclusion of values from a set with no notion of why? Oh dear oh dear.

    OBIEE Magic numbers now abound Snow falls on my soul.

  • Robert Gascoyne-Cecil, 3rd Marquess of Salisbury (unregistered) in reply to dkf
    dkf:
    The more I look at this snippet, the more horrified I feel. Some kind of function that takes 66 parameters? A bizarre exclusion of values from a set with no notion of why? Oh dear oh dear.

    DBA in spring of life, know not the decode function. Keep it that way.

  • Horse_ebooks (unregistered)
    [image]

    should delete the temp files here, no cannot because, we havent read it in yet

  • (cs) in reply to Robert Gascoyne-Cecil, 3rd Marquess of Salisbury
    Robert Gascoyne-Cecil:
    DBA in spring of life, know not the decode function. Keep it that way.
    Poet's good advice like spring sunshine on my face. Shame it's not haiku!
  • (cs) in reply to JJ what J
    JJ what J:
    QJo:
    That tmpnum one ... just looks like some interpolation is being done. Further info needed, but doesn't seem as WTFish as all that.
    You suck. USing that many temporary variables with stupid names and no comment to explain is always a FAIL
    And you deserve a sound spanking, you irksome child.
  • (cs) in reply to n_slash_a
    n_slash_a:
    code:
    tmpnum6 = tmpnum2 + tmpnum * (tmpnum4 - tmpnum2); tmpnum7 = tmpnum3 + tmpnum * (tmpnum5 - tmpnum3); tmpnum8 = tmpnum6 + tmpnum1 * (tmpnum7 - tmpnum6);
    TRWTF is using 'tmp' instead of 'temp' to denote a temporary variable

    Sometime I use variable like temp1, temp2 when doing construction of code activity. Then during code review process it is discovered and changed to meet CMM5 level. That is advantage of CMM.

  • (cs) in reply to PiisAWheeL
    PiisAWheeL:
    Lockwood:
    5.8.5. Fail. Brass falls down towards the ground

    I was counting towards as 1 syllable... sometimes my memory gets retarded on me. Anything else you want to nitpick at today?

    Its been a while, maybe it was brass spirals towards the ground.... I no longer care.

    Most Americans pronounce "towards" as one syllable. Then again, it's really supposed to be seven morae, and I think towards could count as two in either British or American English.

  • (cs)

    Kinda feels like it should be a haiku...

    The pig go. Go is to the fountain. The pig put foot. Grunt. Foot in what? ketchup. The dove fly. Fly is in sky. The dove drop something. The something on the pig. The pig disgusting. The pig rattle. Rattle with dove. The dove angry. The pig leave. The dove produce. Produce is chicken wing. With wing bark. No Quack.

  • DanDan (unregistered)

    I wish I were first So I could write a comment To annoy, like frist

  • Dave-Sir (unregistered) in reply to Bob
    Bob:
    The theory that a haiku contains 17 syllables and that there's anything special about this is singularly a geek meme.

    That this is also considered a form or poetry demonstrates that most geeks should stick to what they're good at.

    For future reference, things you might find in a good haiku: . 17 morae . a seasonal reference . a juxtaposition separated with a "cut"

    Anyone can write haiku. Just stop after the seventeenth syllab

    laoreet!

  • hashishin (unregistered) in reply to MrBester

    o'rly? in which hex?

  • foo (unregistered) in reply to bashō
    bashō :
    Bob:
    17 morae a seasonal reference juxtaposition

    FTFY

    Zero-x-one-one, winter, spring, summer and fall, form vs. content.

  • foo (unregistered) in reply to DCRoss
    DCRoss:
    MrBester:
    256 is 80 in hex so there's a new WTF
    Yes, that is a new WTF. When did people start referring to base 32 as "hex"?
    Hex(a) is six in Greek, and 32 is clearly 26 (in base 13).
  • (cs) in reply to Nagesh
    Nagesh:
    Sometime I use variable like temp1, temp2 when doing construction of code activity. Then during code review process it is discovered and changed to meet CMM5 level. That is advantage of CMM.
    CMM5_temp6 = CMM5_temp2 + CMM5_temp * (CMM5_temp4 - CMM5_temp2); 
    CMM5_temp7 = CMM5_temp3 + CMM5_temp * (CMM5_temp5 - CMM5_temp3); 
    CMM5_temp8 = CMM5_temp6 + CMM5_temp1 * (CMM5_temp7 - CMM5_temp6);
    
    Cannot see such a big advantage...
  • Buddy (unregistered)

    Everybody knows All the best haikus end with "Boy becomes a man."

  • Jay (unregistered) in reply to DCRoss
    DCRoss:
    MrBester:
    256 is 80 in hex so there's a new WTF
    Yes, that is a new WTF. When did people start referring to base 32 as "hex"?

    "Hex" is base 32 ... if you are expressing the base in base 4 1/2.

  • Jay (unregistered)

    The funny thing about the re-implementation of the "!" operator is that he uses "!" in the function. So apparently he is aware that this operator exists and knows how to use it.

    It's like when you ask someone to define a word and he uses that word in the definition: "What does 'eludicate" mean?" "Well, it's like, ya know, when you elucidate something."

  • Jay (unregistered) in reply to Bob
    Bob:
    The theory that a haiku contains 17 syllables and that there's anything special about this is singularly a geek meme.

    That this is also considered a form or poetry demonstrates that most geeks should stick to what they're good at.

    For future reference, things you might find in a good haiku: . 17 morae . a seasonal reference . a juxtaposition separated with a "cut"

    Ah, but when we try to write a Haiku in English, it's a little tough to literally follow the "17 morae" rule, because, you see, there is no such thing as a "morae" in English. So we take the closest equivalent: syllables. Or to put it another way:

    Seventeen "morae" Make Japanease Haiku but Adapt for English

  • Jay (unregistered)

    Please be sensitive My son wrote haikus, and note No laughing matter

  • Jay (unregistered) in reply to PiisAWheeL
    PiisAWheeL:
    I was counting towards as 1 syllable... sometimes my memory gets retarded on me. Anything else you want to nitpick at today?

    How many syllables do you want to count it as? I just checked thefreedictionary.com, and they give three pronunciations, the first two being a single syllable.

  • Jeff Grigg (unregistered)

    I'll assert that it's not /all that crazy/ to write a "testNothing" method in a JUnit class. ...based on the fact that I have done it a few times. It's usually not an ideal situation. It usually happens when you find you need to "comment out" other test methods, from time to time, due to the tests being very sensitive and some changes (possibly done by careless team members who don't run the tests!) break tests.

    JUnit fails any test class that contains no test methods. So if you end up disabling all the test methods in a class, you're stuck -- unless you want to delete the class.

    And if you're at a company that uses static code analysis rigorously, then the static code analysis will find the empty method objectionable. (That, in itself, can be a problem, because an empty do-nothing method can be quite correct for some subclasses using the Template design pattern. But that's another issue.) But, honestly, some programmers will put 'assertTrue(true);' just because they think that JUnit (or their coding standard) requires one and only one assert in each test method.

    Sometimes these things are more, "Dude; that's just stupid", rather than a full "WTF!?!"

  • Tired Memery (unregistered) in reply to PiisAWheeL

    Once adventured too; Took an arrow to the knee; Now a common guard.

  • (cs)

    Sigh So many magic numbers, so little time.

    At least the guy who defined EIGHTY did it right. Of course, it would have helped a bit if he'd actually gone to the trouble of:

    #define EIGHTY 0x80

  • JJ (unregistered) in reply to Coyne
    Coyne:
    *Sigh* So many magic numbers, so little time.

    At least the guy who defined EIGHTY did it right. Of course, it would have helped a bit if he'd actually gone to the trouble of:

    #define EIGHTY 0x80

    TRWTF is reading hex numbers as if they were decimal.

    #define EIGHT_OH 128

    I'm happy now.

  • x (unregistered)
        int i = 1;
        while (i < i + 1)
            cout << "FILE_NOT_FOUND";
    
  • Jay (unregistered) in reply to x
    x:
        int i = 1;
        while (i < i + 1)
            cout << "FILE_NOT_FOUND";
    

    Wait, there's a bug. I think you mean:

    int i=1;
    while (i < i + 1)
    {
      cout << "FILE_NOT_FOUND";
      ++i
    }
    
  • Jay (unregistered) in reply to JJ
    JJ:
    Coyne:
    *Sigh* So many magic numbers, so little time.

    At least the guy who defined EIGHTY did it right. Of course, it would have helped a bit if he'd actually gone to the trouble of:

    #define EIGHTY 0x80

    TRWTF is reading hex numbers as if they were decimal.

    #define EIGHT_OH 128

    I'm happy now.

    Who says decimal "80" is "eighty" but hex "80" is eight-oh? Maybe it's the other way around. I think you're reading decimal numbers as if they were hex.

  • x (unregistered) in reply to Jay
    Jay:
    x:
        int i = 1;
        while (i < i + 1)
            cout << "FILE_NOT_FOUND";
    

    Wait, there's a bug. I think you mean:

    int i=1;
    while (i < i + 1)
    {
      cout << "FILE_NOT_FOUND";
      ++i
    }
    

    5-7-5, dude.

  • Spudley (unregistered)

    I've just written a do-nothing unit test exactly like the one here.

    The reason for it is this:

    I'm configuring a Jenkins build server for an old project. The project currently doesn't have any unit tests.

    For now my task is the build server, but we do intend to write tests for the project, so I need to have the xUnit functionality working in the build.

    So I've written a dummy unit test so I can get Jenkins doing its thing.

    I don't think this is a wrong at all. The example in the article here was well labeled as doing nothing; I can easily envision it having been written for a similar purpose. Perhaps the only sin here is that it wasn't subsequently deleted once its usefulness had passed.

Leave a comment on “Schizophrenic Haiku Comments and More”

Log In or post as a guest

Replying to comment #:

« Return to Article