Why programmers have big lumps on their heads

Discussion in 'Mac Programming' started by Doctor Q, Sep 26, 2005.

  1. Doctor Q Administrator

    Doctor Q

    Staff Member

    Sep 19, 2002
    Los Angeles
    No, our skulls are not bigger to hold larger-than-average brains. We have lumps on our heads from banging them on the wall when things like this happen:

    I use a program every morning to display a list of recent changes to a customer database, as a double-check that things look fine. This way, if there is a problem in the database system, say from an errant automated process, I will notice that a large number of records have been added, removed, or changed, and I can check that it was intentional.

    I wrote the program myself and it's worked fine for over a year. Today I turned over the task of running the program to a coworker who has inherited the task. But it didn't work when he tried it! I made sure it had nothing to do with his login name (the program doesn't care who runs it and it uses the database under the same credentials no matter who runs it). So it was clearly impossible that it always worked for me and failed for him, right?

    After banging on my head on the wall for a while (the usual technique for programmers to solve impossible problems), I discovered the problem wasn't getting solved, so I went to Plan B: debugging the program. I'm sure you'd like to know what the answer turned out to be.

    Answer: The program used a temporary filename based on the operating system process ID, and a form in which the filename was used had a field with a limited character size. If the script was run early in the day when process IDs were lower on a system that was booted each day, the process ID was four digits long and the filename field fit on the form. If the script was run later in the day when process IDs were higher, the process ID was five digits long and the filename field was truncated!

    I ran the program first thing each day. My coworker tried it in the afternoon. Sure enough, when I shortened the temporary filename, it started working for him too. At any time of day!

    The problem is solved, but I seem to have a lump on my head. Thanks for listening.
  2. lopresmb macrumors 6502

    Apr 29, 2005
    well congrats, I suppose all's well that ends well (except the head thing). Just keep reminding yourself - you are smarter than the machine, he works for you :D. That and just make sure the head blows don't land on the actual computer, which has the unfortunate likelyhood of rendering the hardware you are working with inneffective ;)
  3. Mitthrawnuruodo Moderator emeritus


    Mar 10, 2004
    Bergen, Norway
    He-he... the solution is always trivial once identified... :)

    At least it wasn't one of those bugs that spawn a whole new gang of bugs once you correct the original... or so it seems at least... ;)

    And I normally don't get the lumps on my (fore)head until the bug is found, and then only because I bang my head against the table for being so stupid not to find it earlier... :D
  4. Mr. Anderson Moderator emeritus

    Mr. Anderson

    Nov 1, 2001
    why did you limit yourself on the temporary file name? I'm thinking its one of those things that seemed ok at the time - but in hindsight, making a temporary file that you create and delete from the program - you could have just made it the same every time - like tempfile.txt or whatever :D

    How long did it take you to figure out the problem? That one seems like a pain.

  5. Doctor Q thread starter Administrator

    Doctor Q

    Staff Member

    Sep 19, 2002
    Los Angeles
    I don't use the same temporary filename each time because two people, in theory, could use the program at the same time and each would need a distinct temporary file. Using the process ID in the filename is a standard trick.

    It didn't take me long to track down the problem, as it turns out, because I had built in some debugging options to show you the progress as it executed. When it claimed to have created a file but then was unable to find it, I looked in the target folder and found a filename that had a digit missing at the end. Aha!
  6. dcv macrumors G3

    May 24, 2005
    i was curious about this thread...

    here's what it looks like from the index page!
  7. VanMac macrumors 6502a


    May 26, 2005
    Rampaging Tokyo
    I fell off a cliff when I was younger, landed on my head, and got a pretty knarly bump and gash still today. It explains a lot. :confused:
  8. Lacero macrumors 604


    Jan 20, 2005
    There's an opportunity to come up with a great dirty joke in there somewhere. :p
  9. clayj macrumors 604


    Jan 14, 2005
    visiting from downstream
    Egos? ;)
  10. dcv macrumors G3

    May 24, 2005
    My comment was intentionally left open to interpretation... but i'm sure you can guess what i was thinking...

    pay-cheques *of course*

    believe that, you'll believe anything...i'm a cheeky girl really... hehe

Share This Page