• (cs)
    Alex Papadimoulis:

    It's been a while since I've done a smorgasbord post, so here goes ...


    DM discovered the source of some rather ... unprofessional ... error messages in the log files ...

    try
    {
      /* SNIP: 15 lines */
    }
    catch
    {
      //How did this happen??
      log.fatal("Aaaaarrrgghhhh");
    }

    Finally, production code that produces an error message recreating part of my reaction when some Java or C++ code fails to compile. I usually throw in a few obscenities, though, just for the heck of it.

    You know what? I think I can make this better...

    try
    {
      /* SNIP: 15 lines */
    }
    catch
    {
      //How did this happen??
      log.fatal("WTF???????????????????????????");
    }

  • (cs)
    Alex Papadimoulis:

    Shayne Studdard chuckled at the original authors comment while porting the old ASP code into the ASP.NET ...

    var aLeapYears = 
    new Array(1900,1904,1908,1912,1916,1920,1924,1928,1932,1936,
    1940,1944,1948,1952,1956,1960,1964,1968,1972,1976,
    1980,1984,1988,1992,1996,2000,2004,2008,2012,2016,
    2020,2024,2028,2032,2036,2040,2044,2048,2052,2056,
    2060) //please god let this be far enough??

    the real WTF is that 1900 is not even a leap year. dork!

    http://www.dpbsmith.com/leapyearfaq.txt

  • Manni (unregistered)

    I'm ashamed to admit that I've done the zero-padding code before, but in my defense it would only pad one or two zeros to the front of a number string. Then I learned about

    Do Until Len(myNumStr) >= 5
       myNumStr = "0" & myNumStr
    Loop

    I can't believe it's not butter.

  • (cs)
    Alex Papadimoulis:

    Shayne Studdard chuckled at the original authors comment while porting the old ASP code into the ASP.NET ...

    var aLeapYears = 
    new Array(1900,1904,1908,1912,1916,1920,1924,1928,1932,1936,
    1940,1944,1948,1952,1956,1960,1964,1968,1972,1976,
    1980,1984,1988,1992,1996,2000,2004,2008,2012,2016,
    2020,2024,2028,2032,2036,2040,2044,2048,2052,2056,
    2060) //please god let this be far enough??

    And he got it wrong!  The formula isn't tough...

    In no particular language (Year%400 == 0) OR ((Year%4 == 0) AND NOT (Year%100 == 0))

    And I suppose I'll wrap it up with this bit from TomA, who shows us yet another way to zero-pad a number

    $limit = 9999;
    for($i=1000;$i<$limit;$i++) 
    {
      $number = "$i";
      if ($i<10) $number = "0".$number;
      if ($i<100) $number = "0".$number;
      if ($i<1000) $number = "0".$number;
      if ($i<10000) $number = "0".$number;
      if ($i<100000) $number = "0".$number;
      [ ... snip ...]
    }


    Nice use of fall through.  It is almost 'case' like.  If it isn't someplace where I care about performance or memory management, I'd leave it just for its aesthetic qualities.
  • (cs)
    Alex Papadimoulis:

    DM discovered the source of some rather ... unprofessional ... error messages in the log files ...

    try
    {
      /* SNIP: 15 lines */
    }
    catch
    {
      //How did this happen??
      log.fatal("Aaaaarrrgghhhh");
    }


    For this coder, it is always September 19th.
  • (cs) in reply to Manni
    Anonymous:

    I'm ashamed to admit that I've done the zero-padding code before, but in my defense it would only pad one or two zeros to the front of a number string. Then I learned about

    Do Until Len(myNumStr) >= 5
       myNumStr = "0" & myNumStr
    Loop

    I can't believe it's not butter.

    or 
    int myNum=12345;
    System.out.println(("0000000000"+myNum).substring((myNum+"").length()));

  • boohiss (unregistered)
    Support : I'm telling you, nothing changed!!! The only difference between the old version and the new version is that the old version was in COBOL, and the new one is in C!!!

    Why doesn't anyone stick up for support? That's only 4 letters difference!

  • (cs) in reply to boohiss

    <font size="2">He misspelled "Aaaaaarrrgghhhh".</font>

  • (cs)
    Alex Papadimoulis:

    Chris Reigrut recalls a conversation with a technical support guy years back when he had a problem with one of their products ...

    Chris : We're having problems with the new version of your software.
    Support : That can't be. We didn't change anything.
    Chris : Well, I uninstalled the new version and put the old one back on, and the problem went away. I then reinstalled the new version, and the problem came back.
    Support : No, it can't be our software. We didn't change anything!
    ( ... Lots of back and forth about my analysis of the problem ...)
    Chris : So you're telling me that you sent out an update, but you didn't change anything. If that's the case, what's the point of the update?
    ( ... More back and forth, Support getting more and more exasperated ...)
    Support : I'm telling you, nothing changed!!! The only difference between the old version and the new version is that the old version was in COBOL, and the new one is in C!!!

    I think Alex forgot to post the rest of this conversation. I'm sure it goes something like this...

    Support: What do you mean C and COBOL are different "languages"? They're both in English, I think.

    Chris: *&$#@*%#

    Support: So you mean C is not short for COBOL?

    Chris: *$&#@*$#

  • -L (unregistered)
    Alex Papadimoulis:

    try
    {
      /* SNIP: 15 lines */
    }
    catch
    {
      //How did this happen??
      log.fatal("Aaaaarrrgghhhh");
    }

    I occasionally use errors like this, especially when debugging an application. Provided that every 'unprofessional' error message is unique, such expressions are very easy to search for in the source code. A search for 'error' might give you 100 matches, but 'Aaaaarrrgghhhh' is most likely to give just one match.

    From production these are of course removed, since they are unprofessional.
  • (cs)
    Alex Papadimoulis:
    The customer service at Jason Harmon's had been telling clients that the bad data coming seen in their system was a configuraiton problem, not a code problem. A client finally complained enough to get the problem pushed back to development where Jason learned that this just might be a coding problem after all ...

    private bool IsValid() 
    {
    return true;
    }


    This is neither a configuration nor a code problem, it is a philosophical problem. Or rather, a non-problem, because IsValid is of course trivially true.
  • lucky (unregistered)
    Alex Papadimoulis:

    Shayne Studdard chuckled at the original authors comment while porting the old ASP code into the ASP.NET ...

    var aLeapYears = 
    new Array(1900,1904,1908,1912,1916,1920,1924,1928,1932,1936,
    1940,1944,1948,1952,1956,1960,1964,1968,1972,1976,
    1980,1984,1988,1992,1996,2000,2004,2008,2012,2016,
    2020,2024,2028,2032,2036,2040,2044,2048,2052,2056,
    2060) //please god let this be far enough??



    Equation to see if it is "far enough":

    ((truncate(((60 - current age) + current year) / 10)) * 10) + 20 (to not screw the next gen too)

    code for that current year was probably 2003

    which puts that programmer between the ages of 14 and 23
  • (cs) in reply to -L

    How many times does an error message have to be used, before it gains professional status?  Or is it governed by a certification test? </humor>

  • (cs)
    Alex Papadimoulis:

    And I suppose I'll wrap it up with this bit from TomA, who shows us yet another way to zero-pad a number

    $limit = 9999;
    for($i=1000;$i<$limit;$i++) 
    {
      $number = "$i";
      if ($i<10) $number = "0".$number;
      if ($i<100) $number = "0".$number;
      if ($i<1000) $number = "0".$number;
      if ($i<10000) $number = "0".$number;
      if ($i<100000) $number = "0".$number;
      [ ... snip ...]
    }


    I've done something like this before.  Except it wasn't for 9999-digit long numbers, and there was no for-loop involved.  I was using some scripting language I wasn't familar with and didn't want to look up the equivalent of printf() to just pad a number so that it was 3 digits long, so i just did something like the first two if statements.

    And I immediately saw the WTF about the year 1900, but then I saw that several other people had beaten me to it. :)
  • (cs) in reply to -L
    Anonymous:
    From production these are of course removed, since they are unprofessional.


    You've obviously never experienced the joy of having some profainty get tossed to the screen during a customer demo.  Or having a system password, also a profainty, make it into the final documentation.
  • (cs) in reply to -L
    Anonymous:
    Alex Papadimoulis:

    try
    {
      /* SNIP: 15 lines */
    }
    catch
    {
      //How did this happen??
      log.fatal("Aaaaarrrgghhhh");
    }

    I occasionally use errors like this, especially when debugging an application. Provided that every 'unprofessional' error message is unique, such expressions are very easy to search for in the source code. A search for 'error' might give you 100 matches, but 'Aaaaarrrgghhhh' is most likely to give just one match.

    From production these are of course removed, since they are unprofessional.

    Nowadays, I hardly every write UI code, but early in my programming career (10+ years ago now), I wrote a program that did a lot of input validation. And, for various reasons, it was completely text based. No windows or other UI doo-dads. It was written in completely portable C++ and just used iostreams.

    All the input validation messages were very chatty and somewhat silly. They were to the point, and it was obvious what it was complaining about each time, but the tone of the messages was that of a good friend chiding you over a silly mistake.

    The company I worked for was pretty small, and I was the only person on their staff who knew much of anything about the inner-workings (hardware or software) of computers. So the program went into production that way.

    I ended up having to change all the error messages to be 'boring' anyway though. One person on staff complained that in order for him to maintain his professional demeanor and focus in the office, the program had to report the error messages in a dry, neutral tone.

    I was both amused, and slightly irritated. But I did it. :-)

    I sort of think people get way too uptight about stuff like that. I don't really understand why a program can't say "Arrrggghh!" as long as it doesn't confuse anybody.

  • My Name (unregistered)
    Alex Papadimoulis:

    And I suppose I'll wrap it up with this bit from TomA, who shows us yet another way to zero-pad a number

    $limit = 9999;
    for($i=1000;$i<$limit;$i++)
    {
    $number = "$i";
    if ($i<10) $number = "0".$number;
    if ($i<100) $number = "0".$number;
    if ($i<1000) $number = "0".$number;
    if ($i<10000) $number = "0".$number;
    if ($i<100000) $number = "0".$number;
    [ ... snip ...]
    }


    Why all that "if"s if you know the number is always 4 digits long?
  • My Name (unregistered) in reply to My Name
    Anonymous:
    Alex Papadimoulis:

    And I suppose I'll wrap it up with this bit from TomA, who shows us yet another way to zero-pad a number

    $limit = 9999;
    for($i=1000;$i<$limit;$i++)
    {
    $number = "$i";
    if ($i<10) $number = "0".$number;
    if ($i<100) $number = "0".$number;
    if ($i<1000) $number = "0".$number;
    if ($i<10000) $number = "0".$number;
    if ($i<100000) $number = "0".$number;
    [ ... snip ...]
    }


    Why all that "if"s if you know the number is always 4 digits long?


    The board eats half the code...
  • Paul Tomblin (unregistered) in reply to Omnifarious
    Omnifarious:

    I sort of think people get way too uptight about stuff like that. I don't really understand why a program can't say "Arrrggghh!" as long as it doesn't confuse anybody.



    How do you feel about the message "Holy Bat, Fuckman, how did we get here?", which I accidentally left in code that got to a production server?
  • (cs) in reply to Paul Tomblin
    Anonymous:
    Omnifarious:

    I sort of think people get way too uptight about stuff like that. I don't really understand why a program can't say "Arrrggghh!" as long as it doesn't confuse anybody.



    How do you feel about the message "Holy Bat, Fuckman, how did we get here?", which I accidentally left in code that got to a production server?


    Personally, I'd take a screenshot, and mail it to a bunch of friends.
  • (cs) in reply to My Name
    Anonymous:
    Anonymous:
    Alex Papadimoulis:

    And I suppose I'll wrap it up with this bit from TomA, who shows us yet another way to zero-pad a number

    $limit = 9999;
    for($i=1000;$i<$limit;$i++)
    {
    $number = "$i";
    if ($i<10) $number = "0".$number;
    if ($i<100) $number = "0".$number;
    if ($i<1000) $number = "0".$number;
    if ($i<10000) $number = "0".$number;
    if ($i<100000) $number = "0".$number;
    [ ... snip ...]
    }


    Why all that "if"s if you know the number is always 4 digits long?


    The board eats half the code...


    I'd have to see all the code.... but it looks like at the end of the loop you're left with:
    limit = 9999
    i = 9999
    number = "009998" (more 0's depending on how many alex snipped out...)

    and a heck of a lot of wasted cycles for iterating from 1000 to 9999
    wtf???  I hope there's more to this than I can see...
  • John (unregistered) in reply to cconroy
    cconroy:
    <font size="2">He misspelled "Aaaaaarrrgghhhh".</font>
    He must have died while carving it.
  • Xocomil (unregistered) in reply to mlathe

    ummm... it has been a long time since I've coded PHP, so I am probably exposing my gross ignorance, but how does the original code ever produce anything but '09998'?


  • whiskers_ (unregistered) in reply to John

    MP!

  • MrGrudge (unregistered)

    The "Aaaargh!" error is better than one program I had to debug that simply said "Something Wrong".

  • (cs) in reply to MrGrudge

    Anonymous:
    The "Aaaargh!" error is better than one program I had to debug that simply said "Something Wrong".

    Its also better than "Something didn't quite work out."

     

  • joe_bruin (unregistered) in reply to Mikademus
    Mikademus:
    Alex Papadimoulis:
    The customer service at Jason Harmon's had been telling clients that the bad data coming seen in their system was a configuraiton problem, not a code problem. A client finally complained enough to get the problem pushed back to development where Jason learned that this just might be a coding problem after all ...

    private bool IsValid() 
    {
    return true;
    }


    This is neither a configuration nor a code problem, it is a philosophical problem. Or rather, a non-problem, because IsValid is of course trivially true.


    /*
    Is the object's validity not implicit in the asking of the question?  If it were not, would we be asking the question?  It's a very anthropic situation that is far too complicated to discuss in code comments, please refer to the product documentation for more insight.
    */

    <font color="Red"> Something didn't quite work out ...
    - CAPTCHA Validation Incorrect </font>
  • (cs) in reply to Manni
    Anonymous:

    I'm ashamed to admit that I've done the zero-padding code before, but in my defense it would only pad one or two zeros to the front of a number string. Then I learned about

    Do Until Len(myNumStr) >= 5
       myNumStr = "0" & myNumStr
    Loop

    I can't believe it's not butter.



    Or

        myNumStr = String("0", 5 - Len(myNumStr)) & myNumStr
  • (cs) in reply to Maurits
    Maurits:

        myNumStr = String("0", 5 - Len(myNumStr)) & myNumStr


    Oops, got the arguments backwards:
        myNumStr = String(5 - Len(myNumStr), "0") & myNumStr
  • (cs) in reply to Disgruntled DBA
    Disgruntled DBA:
    Anonymous:
    Omnifarious:

    I sort of think people get way too uptight about stuff like that. I don't really understand why a program can't say "Arrrggghh!" as long as it doesn't confuse anybody.



    How do you feel about the message "Holy Bat, Fuckman, how did we get here?", which I accidentally left in code that got to a production server?


    Personally, I'd take a screenshot, and mail it to a bunch of friends.

    And thus was born Alex's screenshot fridays. =D
  • neuro (unregistered) in reply to Xocomil
    Anonymous:
    ummm... it has been a long time since I've coded PHP, so I am probably exposing my gross ignorance, but how does the original code ever produce anything but '09998'?




    please note that it produces 01000 through 09997 in the meantime.
    i would think that the [snip] removed non-wtf-relevant code which was processing the numbers
  • Now, See Here (unregistered) in reply to My Name
    Anonymous:
    Anonymous:
    Alex Papadimoulis:

    And I suppose I'll wrap it up with this bit from TomA, who shows us yet another way to zero-pad a number

    $limit = 9999;
    for($i=1000;$i<$limit;$i++)
    {
    $number = "$i";
    if ($i<10) $number = "0".$number;
    if ($i<100) $number = "0".$number;
    if ($i<1000) $number = "0".$number;
    if ($i<10000) $number = "0".$number;
    if ($i<100000) $number = "0".$number;
    [ ... snip ...]
    }

    void format_it(char *target, int source)
    (
            sprintf(target,"%04d",source);
    }




    Why all that "if"s if you know the number is always 4 digits long?


    The board eats half the code...
  • nathan (unregistered) in reply to mlathe

    And (s)he's the dork?

  • Evan (unregistered) in reply to Maurits
    Maurits:
    Anonymous:

    I'm ashamed to admit that I've done the zero-padding code before, but in my defense it would only pad one or two zeros to the front of a number string. Then I learned about

    Do Until Len(myNumStr) >= 5
       myNumStr = "0" & myNumStr
    Loop

    I can't believe it's not butter.



    Or

        myNumStr = String("0", 5 - Len(myNumStr)) & myNumStr


    Why not Format( CInt(myNumStr), "000000")?

    I don't have VB installed at the moment so can't test it for correctness or efficiency, but I think it's slightly clearer in any case.




  • (cs) in reply to Xocomil
    Anonymous:
    ummm... it has been a long time since I've coded PHP, so I am probably exposing my gross ignorance, but how does the original code ever produce anything but '09998'?


    You're almost exactly right. It will always produce 009998. Hopefully there is some code to transform that into something meaningful, though even then it wouldn't atone for this attrocity of bad programming.
  • (cs) in reply to Evan
    Anonymous:


    Why not Format( CInt(myNumStr), "000000")?

    I don't have VB installed at the moment so can't test it for correctness or efficiency, but I think it's slightly clearer in any case.






    If you wanted to keep it in PHP (which I assume the original WTF is written in) you could simply write.

    $padded_number = str_pad($number_to_pad,$pad_length,'0',STR_PAD_LEFT);

    Makes more sense that way I think.
  • Ben A. (unregistered) in reply to TLLOTS

    I am assuming that the number-padding code does something with the padded numbers in the snipped part of the loop...otherwise it would be a monumental waste of time.

    And yes, it's PHP.  (It could also be valid Perl, except that Perl requires curly brackets around if statements with a single body statement.)

  • Anonymous (unregistered)

    The real WTF in that second one is the misspelling of "license".

  • (cs) in reply to thomas.galvin
    thomas.galvin:
    Anonymous:
    From production these are of course removed, since they are unprofessional.


    You've obviously never experienced the joy of having some profainty get tossed to the screen during a customer demo.  Or having a system password, also a profainty, make it into the final documentation.


    Ding!  Ding!  Ding!  Ding!  We have an analyst trolling!  We have and analyst trolling!  Ding!  Ding!  Ding!  Ding!
  • Nimrand (unregistered)

    Speaking of unprofessional error messages, a few months ago I was trying to teach a coworker how to use CVS.  We use a CVSNT service as our repository.  She was having lots of very strange networking problems on her computer, however.  Appearantly those networking problems were preventing the connection to the repository from working as well.  Imagine my surprise when I tried to check out a module, and the reply I got from the CVSNT service was "I hate you."

  • josh (unregistered)
    Alex Papadimoulis:

    <font face="Courier New" size="2">        </font><font color="#0000ff" face="Courier New" size="2">If</font><font face="Courier New" size="2"> iFile.Exists </font><font color="#0000ff" face="Courier New" size="2">Then</font>

    <font face="Courier New" size="2">            fileSizeBytes = iFile.Length.ToString</font>
    <font face="Courier New" size="2">        </font><font color="#0000ff" face="Courier New" size="2">Else</font>
    <font face="Courier New" size="2">            </font><font color="#008000" face="Courier New" size="2">'Actually this test was done earlier</font>
    <font face="Courier New" size="2">            </font><font color="#008000" face="Courier New" size="2">' - the code wouldn't be here if it didn't exist</font>
    <font face="Courier New" size="2">            </font><font color="#0000ff" face="Courier New" size="2">Throw</font><font face="Courier New" size="2"> </font><font color="#0000ff" face="Courier New" size="2">New</font><font face="Courier New" size="2"> FieldAccessException("File does not exist.")</font>
    <font face="Courier New" size="2">        </font><font color="#0000ff" face="Courier New" size="2">End</font><font face="Courier New" size="2"> </font><font color="#0000ff" face="Courier New" size="2">If</font>


    This is actually a sign of very good code.  I assume there is another test earlier in the code path for iFile.Exists, so execution should not reach this point if the condition is false.  This code is then just a safety net in case the coder missed some case where the first test could be skipped.

    The only problem is that the comment says that the code wouldn't be there when it means that execution would not reach there.
  • Different Anonymous (unregistered) in reply to Evan

    You could use a logarithm for the width of the number... (in VB again.)

    print string(myWidth - int(log(myNum)/2.30258509299403) - 1, "0") + trim(str(myNum))

  • no name (unregistered) in reply to Nimrand
    Speaking of unprofessional error messages, a few months ago I was trying to teach a coworker how to use CVS. We use a CVSNT service as our repository. She was having lots of very strange networking problems on her computer, however. Appearantly those networking problems were preventing the connection to the repository from working as well. Imagine my surprise when I tried to check out a module, and the reply I got from the CVSNT service was "I hate you."

    And did you imeadiatly run to your boss and demand more professional software?

    Or, did you chuckul for a second or two (possibly calling over your coworkers to chuckle too), and then get on with your work?
  • (cs) in reply to Different Anonymous
    Anonymous:

    You could use a logarithm for the width of the number... (in VB again.)

    print string(myWidth - int(log(myNum)/2.30258509299403) - 1, "0") + trim(str(myNum))



    Heh, rounding errors?
  • (cs) in reply to joe_bruin
    Anonymous:
    Mikademus:
    Alex Papadimoulis:
    The customer service at Jason Harmon's had been telling clients that the bad data coming seen in their system was a configuraiton problem, not a code problem. A client finally complained enough to get the problem pushed back to development where Jason learned that this just might be a coding problem after all ...

    private bool IsValid() 
    {
    return true;
    }


    This is neither a configuration nor a code problem, it is a philosophical problem. Or rather, a non-problem, because IsValid is of course trivially true.


    /*
    Is the object's validity not implicit in the asking of the question?  If it were not, would we be asking the question?  It's a very anthropic situation that is far too complicated to discuss in code comments, please refer to the product documentation for more insight.
    */


    <font size="2"> /*
    Is the object's validity not implicit in the asking of the question?  If it were not, would we be asking the question?  It's a very anthropic situation that is far too complicated to discuss in code comments, please refer to the product documentation for more insight.

    This is not a new problem. Heidegger has treated it and the Existentialist approach would be an investigation starting with the (legitimate) question "where lies validitys validness?". However, a more Wittgensteinian (the later Wittgenstein) approach would recognise that this might in fact be a grammatical problem rather than a philosophical one in that by using the noun "validity" we take for granted and posit as real the objective existance of "validness".

    However, the authors of the code refute these essentially nihilistic approches, including post-modernistic conceptions of validity, and instead defines the problem as an analytical one. Thus we see that the question IsValid() in fact contains its own truth condition, and the answer is trivially always true. (Gadamer, Warheit und Metode; Heidegger, Zeit und Zein; Wittgenstein, The Blue and The Brown Book, Tractatus Logico-Philosophicus; Russel, Principa Mathematica)
    */</font>
    private bool IsValid() 
    {
    return true;
    }

  • Steve Kemp (unregistered) in reply to Nimrand
    Anonymous:

    Imagine my surprise when I tried to check out a module, and the reply I got from the CVSNT service was "I hate you."



    The success message for CVS is the matching "I love you"....
  • Avalanche (unregistered) in reply to Anonymous
    The real WTF in that second one is the misspelling of "license".

    Check out a dictionary: both ways are valid!
  • (cs) in reply to Steve Kemp
    Anonymous:
    Anonymous:

    Imagine my surprise when I tried to check out a module, and the reply I got from the CVSNT service was "I hate you."



    The success message for CVS is the matching "I love you"....


    But the opposite of love is indifference.
  • (cs) in reply to RevMike


        try
        {
          /* SNIP: 15 lines */
        }
        catch
        {
          //How did this happen??
          log.fatal("Aaaaarrrgghhhh");
        }


    I've always preferred to preface error messages with "Errah!"

    The author of the code in "Logged to Death" should have used something like this.
    http://www.thedailywtf.com/forums/53224/ShowPost.aspx
  • Benjamin Smith (unregistered) in reply to -L

    When I develop software, the first thing I do is to create a debug() function, and use it to toggle the display of internally reported errors. An example function (in PHP)

    Function DisplayError($msg)
    {
    if (!Debug())
        return true;
    /* display the message by whatever means here /
    }

    With this, code like this works out OK:

    if ($someCondition)
        {
        /
    do something */
        }
    elseif ($otherCondition)
        {
        /*other Something */
        }
    else
        {
        DisplayError("Function foo(): WTF?!?!? How could this happen?");
        }

    I have lots of such code in my application - it makes it much easier to identify when changes to the codebase break previous expectations and assumptions!

    PS: The real WTF is that captcha doesn't work well on this site!

Leave a comment on “Holiday Smorgasbord”

Log In or post as a guest

Replying to comment #:

« Return to Article