• Larry (unregistered)
    the article:
    if (_tblItem.getTable().getModel() != null 
        && _tblItem.getTable() != null 
        && _tblItem != null)
    
    TRWTF is languages that read left-to-right.
  • Bobbo (unregistered)

    I, Robot

  • (cs)
    I can only hope they rolled a die to ensure this was actually random
    And I hope they are in a universe where 215 is actually a prime.
  • Uh... (unregistered)
    public static int RANDOM_PRIME_NUMBER = 215
    Ok, I see how this might be random when he entered it, but I do not see how it is prime.
  • Mad Adder (unregistered)
    "This is in our production code," notes Joseph Daigle, "I can only hope they rolled a die to ensure this was actually random."
    public static int RANDOM_PRIME_NUMBER = 215;
    Hrmm... not random, not a prime number. Looks like we got a winner here.
  • One (unregistered)

    Do we get to have a discussion about whether or not 1 is a prime number?

  • (cs)

    I keep thinking that that getSelf() method should be Private. After all, wouldn't you want to be private while doing some sort of self exam?

  • cynical cynic (unregistered)

    At last, the explanation to all the Bert Glanstrom comments!

    public static boolean isFunnyOrInsightful(comment c)
    {
        return !isFunny(c) && !isInsightful(c);
    }
  • (cs) in reply to TGV
    TGV:
    I can only hope they rolled a die to ensure this was actually random
    And I hope they are in a universe where 215 is actually a prime.

    Maybe that code path is only taken if 1 == 0?

  • Bogolese (unregistered)
    ine
  • Mad Adder (unregistered) in reply to Mad Adder

    And TRWTF is a triple-simul-post... or me just not refreshing in the few seconds it took to type my comment.

  • OPTIMUS PRIME (unregistered)

    If by prime they mean divisible by itself, 1, and 5 then yes, 215 is a prime number.

  • Fibonacci (unregistered)

    "... 3. is for lucky :)"

    priceless <3

  • (cs)
    // Do not remove the following line. HashMaps are crazy and point 
    // to old reference data even if they were instantiated fresh!
    workMap.clear();

    Come on, who among us hasn't sat debugging something so long that the logical conclusion is a conspiracy? Paranoia is the natural mental state.

  • The Nerve (unregistered)

    Fixed?

    //public interface ISelfAware {
    //
    //    /**
    //     * Useful in an MBean so that it can return a live reference to itself as a
    //     * method call
    //     *
    //     * @return reference to this object
    //     */
    //    public ISelfAware getSelf();
    //}
    
    //if(completed == 1)
    //   if(startdate[1] != 2)
          month = startdate[2];
    //   else
    //      month = startdate[2];
    //else
    //   month = startdate[2];
    
    if (&& _tblItem != null != null 
        && _tblItem.getTable() != null 
        _tblItem.getTable().getModel())
    
    /* This program will only run if the laws of mathematics hold
    if(1 == 0) 
    {
        fprintf("Oh crap - we are not running in the correct Universe\n");
        exit(17);
    }*/
    
    public static int FIXED_NONPRIME_NUMBER = 215;
    
    /*3 times because if we have filter on some column - 
      clean only that data, and after that cleans everything 
      else (2.), and the 3. is for lucky :) 
    worksheet.Cells.ClearContents();
    worksheet.Cells.ClearContents(); */
    worksheet.Cells.ClearContents();
    
    Map<TransactionId, List<BillingTransaction>> workMap
        = new HashMap<TransactionsId, List<BillingTransaction>>();
    
    // Do not remove the following line. HashMaps are crazy and point 
    // to old reference data even if they were instantiated fresh!
    //workMap.clear();
    
    public static boolean isNotAlphaNumeric(char c)
    {
        return !isLetter(c) && !isDigit(c);
    }
    
    <!-- <script type="text/javascript">document.write('</div>')</script>
    <p><noscript></div></noscript> --&gt;</p>
    </pre>
    
  • (cs) in reply to One
    One:
    Do we get to have a discussion about whether or not 1 is a prime number?

    Well, it is only integer factorable to 1 and itself so, yes, 1 is prime.

    However, random it is not.

  • Anonymous (unregistered)

    I like the way there appears to be a dedicated error code for "not running in the correct Universe". I'd have gone for -42 instead of 17 but well done anyway. Wait, can you pass negative exit codes? I suppose it doesn't matter, if that error code ever gets returned we have to assume that the apocalypse is upon us.

  • Anon a mouse (unregistered) in reply to OPTIMUS PRIME
    OPTIMUS PRIME:
    If by prime they mean divisible by itself, 1, and 5 then yes, 215 is a prime number.

    Well itself 1, 5 and 43

  • (cs)
    Arnold Vriezekolk writes, "one of the guys on our team likes to be thorough. Very, very thorough."
    /* This program will only run if the laws of mathematics hold */
    if(1 == 0) 
    {
        fprintf("Oh crap - we are not running in the correct Universe\n");
        exit(17);
    } 
    

    Right. Because in your universe fprintf() doesn't need a file pointer.

  • Remy Martin (unregistered)

    I just got done refactoring all the references to logError to wtf and checking it into the application.

  • Short-ed (unregistered)

    Here's another bit of code that I came across recently, taken from production code, of course!

    int16_t wrapCounts( int16_t delta ) {
      const short SIZE_SHORT = 32768;
      int16_t ret;
    
      if (delta < -SIZE_SHORT)
        ret = -(2 * SIZE_SHORT + delta);
      else if (delta > SIZE_SHORT)
        ret = (2 * SIZE_SHORT - delta);
      else
        ret = delta;
    
      return ret;
    }
    

    Enjoy!

    Captcha: feugiat - contrapuntal Fiat

  • (cs) in reply to Markp
    Markp:
    Come on, who among us hasn't sat debugging something so long that the logical conclusion is a conspiracy?
    The sad part is I completely agree with this.
  • notovny (unregistered) in reply to WthyrBendragon

    The standard formulation of the Fundamental Theorem of Arithmetic requires that 1 not be considered a prime number.

  • Old Smith (unregistered)

    I rolled a die while reading this

  • Matt (unregistered) in reply to Short-ed
    Short-ed:
    Here's another bit of code that I came across recently, taken from production code, of course!
    int16_t wrapCounts( int16_t delta ) {
      const short SIZE_SHORT = 32768;
      int16_t ret;
    
      if (delta < -SIZE_SHORT)
        ret = -(2 * SIZE_SHORT + delta);
      else if (delta > SIZE_SHORT)
        ret = (2 * SIZE_SHORT - delta);
      else
        ret = delta;
    
      return ret;
    }
    

    Somebody missed the day when they talked about variables having finite space in memory and not being drawn out of the ether.

  • anon (unregistered)

    For those unable to read this comment, it says: <NoComment>For those unable to read this comment, it says: <NoComment>For those unable to read this comment, it says: <NoComment>For those unable to read this comment, it says: <NoComment>For those unable to read this comment, it says: <NoComment>For those unable to read this comment, it says: <NoComment>For those unable to read this comment, it says:

  • An Non (unregistered)

    Actually I think I know what the ISelfAware is trying to achieve - bypassing the proxy logic and pass a direct reference to the original java object when instantiated within the same JVM. Messy and badly named... but I worryingly believe I understand what they meant to achieve (i.e. a badly thought out early optimisation)

  • (cs) in reply to Old Smith
    Old Smith:
    I rolled a die while reading this
    http://xkcd.com/221/
  • Bert Glanstron (unregistered) in reply to cynical cynic

    Dear cynical cinic,

    In case you can’t tell, this is a meta-joke comment. The fact that you insist on bashing people who beat old memes clearly shows that you’re too mature and too intelligent to be posting on TDWTF.

    Go back to your Starbucks.

    Sincerely, Bert Glanstron

    [Captcha: commoveo - The people's SUV!]

  • Ancient Mathematician (unregistered) in reply to WthyrBendragon
    WthyrBendragon:
    One:
    Do we get to have a discussion about whether or not 1 is a prime number?

    Well, it is only integer factorable to 1 and itself so, yes, 1 is prime.

    However, random it is not.

    Well, if you were old enough, you'd know that 1 is not even a number, so it can't be a prime. And if you're young enough, you should know that 1 is a unit, so it can't be a prime. Only if you're stuck some time between -200 and 1900 is 1 a prime.

  • Anonymous (unregistered) in reply to frits
    frits:
    /* This program will only run if the laws of mathematics hold */
    if(1 == 0) 
    {
        fprintf("Oh crap - we are not running in the correct Universe\n");
        exit(17);
    }
    Right. Because in your universe fprintf() doesn't need a file pointer.
    You can't just assume this is C/C++. Plenty of other languages have an fprintf function and not all require a file pointer. In Matlab, for example, the fprintf function writes to the screen if no file ID is provided.
  • Anonymous Kernel Hacker (unregistered)

    I think certain versions of Linux have included the line

    if(false)panic();

    just to verify that boolean logic is operating correctly.

  • briggs davis (unregistered) in reply to The Nerve
    The Nerve:
    Fixed?
    //public interface ISelfAware {
    //
    //    /**
    //     * Useful in an MBean so that it can return a live reference to itself as a
    //     * method call
    //     *
    //     * @return reference to this object
    //     */
    //    public ISelfAware getSelf();
    //}
    

    //if(completed == 1) // if(startdate[1] != 2) month = startdate[2]; // else // month = startdate[2]; //else // month = startdate[2];

    if (&& _tblItem != null != null && _tblItem.getTable() != null _tblItem.getTable().getModel())

    /* This program will only run if the laws of mathematics hold if(1 == 0) { fprintf("Oh crap - we are not running in the correct Universe\n"); exit(17); }*/

    public static int FIXED_NONPRIME_NUMBER = 215;

    /*3 times because if we have filter on some column - clean only that data, and after that cleans everything else (2.), and the 3. is for lucky :) worksheet.Cells.ClearContents(); worksheet.Cells.ClearContents(); */ worksheet.Cells.ClearContents();

    Map<TransactionId, List<BillingTransaction>> workMap = new HashMap<TransactionsId, List<BillingTransaction>>();

    // Do not remove the following line. HashMaps are crazy and point // to old reference data even if they were instantiated fresh! //workMap.clear();

    public static boolean isNotAlphaNumeric(char c) { return !isLetter(c) && !isDigit(c); }

    <!-- <script type="text/javascript">document.write('</div>')</script> <noscript></div></noscript> -->

    ironically, your comment contains many comments.

  • Dani Messerman (unregistered) in reply to OPTIMUS PRIME

    No, because it's also divisible by 43 :)

  • (cs)

    Actually, no, it's bloody Akismet, which wouldn't let me post the source of the mangled link in the article because it looked spammy, but is perfectly happy to let me post this link http://pastebin.com/J5tAekpK to the post content instead.

  • Dani Messerman (unregistered) in reply to OPTIMUS PRIME
    OPTIMUS PRIME:
    If by prime they mean divisible by itself, 1, and 5 then yes, 215 is a prime number.
    Forgot to quote this in my previous comment ^^
  • (cs) in reply to Anonymous
    Anonymous:
    frits:
    /* This program will only run if the laws of mathematics hold */
    if(1 == 0) 
    {
        fprintf("Oh crap - we are not running in the correct Universe\n");
        exit(17);
    }
    Right. Because in your universe fprintf() doesn't need a file pointer.
    You can't just assume this is C/C++. Plenty of other languages have an fprintf function and not all require a file pointer. In Matlab, for example, the fprintf function writes to the screen if no file ID is provided.

    OK, you out-nerded me there (that's not difficult, btw). You could also come up with some #define scenario that would allow that (or a user function prototype). However, snippets posted on TDWTF is supposed to be professional production code, so please don't mention Matlab. Additionally, those aren't Matlab comments, are they?

  • v (unregistered) in reply to Uh...
    Uh...:
    public static int RANDOM_PRIME_NUMBER = 215
    Ok, I see how this might be random when he entered it, but I do not see how it is prime.

    public static NOT_RANDOM_NOT_PRIME_BUT_PROBABLY_NOT_A_NUMBER = 215

  • NullPointerException (unregistered) in reply to frits
    frits:
    However, snippets posted on TDWTF is supposed to be professional production code, so please don't mention Matlab.
    I would be pretty surprised if there wasn't at least one case of someone using Matlab for production purposes.
  • itsmo (unregistered) in reply to One
    One:
    Do we get to have a discussion about whether or not 1 is a prime number?

    Do we get to have a discussion about whether or not 1 is a number?

    FTFY

  • Anonymous (unregistered) in reply to Ancient Mathematician
    Ancient Mathematician:
    WthyrBendragon:
    One:
    Do we get to have a discussion about whether or not 1 is a prime number?

    Well, it is only integer factorable to 1 and itself so, yes, 1 is prime.

    However, random it is not.

    Well, if you were old enough, you'd know that 1 is not even a number, so it can't be a prime. And if you're young enough, you should know that 1 is a unit, so it can't be a prime. Only if you're stuck some time between -200 and 1900 is 1 a prime.
    Hey there Ancient Mathematician, you might be just the person I need to help me with an ancient Roman math problem. The following sum is written in Roman numerals. Can you solve it and provide your answer also in Roman numerals?

    (IV + I) - V = ?

  • (cs) in reply to Anonymous Kernel Hacker

    And don't forget the code I found a very long time ago, in the Technical Reference manual for the IBM PC/XT (or maybe it was the PC/AT - I said it was a long time ago). This was the time when IBM published the assembly source of the BIOS in the Tech Ref manual, and the first few instructions executed after the escape from 0FFFFh:0000-land[1] consisted of stuffing a value into one of the machine's 16-bit registers and proving that it could be passed from register to register, hitting all of them. If the original value did not emerge at the other end, the BIOS panicked.

    [1] All versions of the 8086 processor family start in something that approximates to the 8086's real mode (exception: the 80376 started in protected mode as it was an abortive attempt to get away from real mode. It failed in the market) at a 16:16 address of 0xFFFF:0x0000. They have 16 bytes to jump somewhere else before they fall off the end of the world and start executing the real-mode interrupt vector table. It is a really good idea to make sure that this part of the BIOS ROM contains just a far jump.

  • Oh THAT Brian! (unregistered) in reply to OPTIMUS PRIME

    Also divisible by 43 - really a good example of a random prime number!

  • anon (unregistered) in reply to Markp
    Markp:
    // Do not remove the following line. HashMaps are crazy and point 
    // to old reference data even if they were instantiated fresh!
    workMap.clear();

    Come on, who among us hasn't sat debugging something so long that the logical conclusion is a conspiracy? Paranoia is the natural mental state for a software developer.

    FTFY

  • (cs) in reply to Anonymous
    Anonymous:
    Hey there Ancient Mathematician, you might be just the person I need to help me with an ancient Roman math problem. The following sum is written in Roman numerals. Can you solve it and provide your answer also in Roman numerals?

    (IV + I) - V = ?

    Ah, but you forget that the things we call Roman numerals were for writing down numbers, not for performing arithmetic. One of the principal advantages of the modern versions of Arabic numerals (the 0..9 system that we use today) is that they use the same notation for writing down numbers and for doing arithmetic. The Romans used a form of abacus (note that the wire-and-bead calculators that we call abacuses are in fact NOT abacuses) when performing non-trivial arithmetic.

    All that, of course, does not change the fact that there is no way to use Roman number-recording-notation to write zero.

  • (cs)
    "I could make a smart-ass comment about needing a reference to get a reference, but I think the code speaks for itself."
    So make the method static!

    Really, some people know nothing about programming.

  • THE NUMBER ONE (unregistered) in reply to itsmo

    Do we get to have a discussion about whether or not I am a number?

    FTFY

  • Pyrexkidd (unregistered) in reply to notovny
    notovny:
    The standard formulation of the Fundamental Theorem of Arithmetic requires that 1 not be considered a prime number.
    An element p of the ring D, nonzero and not a unit, is called prime if it can not be decomposed into factors p=ab, neither of which is a unit in D.
    http://primes.utm.edu/notes/faq/one.html

    and now it is all clear. whew.

  • itsmo (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    Anonymous:
    Hey there Ancient Mathematician, you might be just the person I need to help me with an ancient Roman math problem. The following sum is written in Roman numerals. Can you solve it and provide your answer also in Roman numerals?

    (IV + I) - V = ?

    Ah, but you forget that the things we call Roman numerals were for writing down numbers, not for performing arithmetic. One of the principal advantages of the modern versions of Arabic numerals (the 0..9 system that we use today) is that they use the same notation for writing down numbers and for doing arithmetic. The Romans used a form of abacus (note that the wire-and-bead calculators that we call abacuses are in fact NOT abacuses) when performing non-trivial arithmetic.

    All that, of course, does not change the fact that there is no way to use Roman number-recording-notation to write zero.

    There is also a way of doing arithmetic with Roman numerals:

    http://mathforum.org/dr.math/faq/faq.roman.html#calc

    BTW Askimet is a fucking idiot - can't put URL tags round this^^

  • Anonymous (unregistered) in reply to frits
    frits:
    Anonymous:
    frits:
    /* This program will only run if the laws of mathematics hold */
    if(1 == 0) 
    {
        fprintf("Oh crap - we are not running in the correct Universe\n");
        exit(17);
    }
    Right. Because in your universe fprintf() doesn't need a file pointer.
    You can't just assume this is C/C++. Plenty of other languages have an fprintf function and not all require a file pointer. In Matlab, for example, the fprintf function writes to the screen if no file ID is provided.
    OK, you out-nerded me there (that's not difficult, btw). You could also come up with some #define scenario that would allow that (or a user function prototype). However, snippets posted on TDWTF is supposed to be professional production code, so please don't mention Matlab. Additionally, those aren't Matlab comments, are they?
    No, those aren't Matlab comments. Matlab was just a random example of a language with its own implementation of fprintf but you're right, the less said about it the better. Weak dynamic typing is surely the work of the devil (great source of WTF though).

Leave a comment on “ISelfAware, Very Thorough, Crazy Hashmaps, and More”

Log In or post as a guest

Replying to comment #:

« Return to Article