• kibedodo (unregistered)

    This is literate programming, isn't it?

  • Edward Royce (unregistered) in reply to Sander Hoogendoorn
    Sander Hoogendoorn:
    I've read carefully throughout all the comments on this peculiar post. Didn't anybody notice that the developers of this beautifully titled method aren't even aware of the abundant use of boolean logic in this code? Maybe it's because I'm a bit authistic, but if people write code like this:
    if (electionDate < DateTime.Today)
        {
            chkApplyUpdateToMainAndFutureRecords.Checked = false;
        }
        else
        {
            chkApplyUpdateToMainAndFutureRecords.Checked = true;
        }
    

    I just have to refactor it. Just can't leave this poor method like this. I would suggest the following line of code.

    chkApplyUpdateToMainAndFutureRecords.Checked = (electionDate < DateTime.Today);
    

    Hmmm.

    I'm probably wrong for doing this but I generally prefer to code the first way rather than the second. Mostly to ensure that the code is as obvious and explicit as possible. You can never tell who is going to replace you, or work with you, so I try to make code as idiot-proof as possible.

  • Jay (unregistered) in reply to Sander Hoogendoorn
    Sander Hoogendoorn:
    Maybe it's because I'm a bit authistic, but if people write code like this:
    if (electionDate < DateTime.Today)
        {
            chkApplyUpdateToMainAndFutureRecords.Checked = false;
        }
        else
        {
            chkApplyUpdateToMainAndFutureRecords.Checked = true;
        }
    

    I once worked on a (COBOL) program that was filled with statements like:

    if transaction-amount = 0
      add transaction-amount to total-amount.
    

    I asked the programmer what the "if" was for. If it was zero, wouldn't adding it in result in not changing the total anyway? He explained that this would run faster because it would save the time to do the add when it wasn't necessary. I tried to explain that an "if" statement takes longer than an add, so even in the cases where it was zero, his version would take longer. I don't think he even understood what I was saying.

    And I just recently was working on a Java program with the fascinating code block:

    if (purchaseOrderNumber1.compareTo(purchaseOrderNumber2)<0)
    {
      ... whole bunch of work ...
    }
    else if (purchaseOrderNumber1.compareTo(purchaseOrderNumber2)>0)
    {
       ... whole bunch of work, line-for-line identical to the previous whole bunch of work ...
    }
    

    I changed this to "purchaseOrderNumber1.compareTo(purchaseOrderNumber2)!=0" and consolidated the two blocks of code. I considered using "equals" but thought just barely maybe there might be some catch to that. The original programmer complained loud and long (about this and several other similar changes) that I was screwing up his code, went to my boss and my boss's boss to say that this could introduce all sorts of difficult-to-find bugs, and demanded I restore it from SVN. The boss finally said to change it back to get him to shut up.

  • (cs)

    The real WTF is the curly braces on a line by themselves.

    Wait... converting the good way of using braces to the annoying way would be a good way to check in more lines of code...

  • ShatteredArm (unregistered)

    I don't like to read threads before commenting--has anyone mentioned the Diebold voting machines yet?

  • (cs) in reply to ShatteredArm
    ShatteredArm:
    I don't like to read threads before commenting--has anyone mentioned the Diebold voting machines yet?
    You utter bastard!

    Does that mean I have to read the whole thread?

    I'm not sure my failing eyesight can cope with this.

  • (cs) in reply to wee
    wee:
    The real WTF is the curly braces on a line by themselves.

    Wait... converting the good way of using braces to the annoying way would be a good way to check in more lines of code...

    Good point. Digg yourself +infinity.

  • (cs) in reply to Sander Hoogendoorn
    Sander Hoogendoorn:
    I've read carefully throughout all the comments on this peculiar post.
    Don't do that.

    It's never worth it.

    Trust me, it really isn't.

  • iToad (unregistered)

    This sort of thing, and a lot of other WTFs, occur because it is simply too easy for anybody to write code.

    If we went back to entering software only on 80-column punched cards, people would have to actually think before they coded.

    Besides, what's wrong with using "A", "BG01F" and "II' as function or variable names anyway?

  • Zoopaloola (unregistered) in reply to Anonymous Cow-herd

    But German agglutination is so expressive and we really miss it in other languages ;-) But I do not see any agglutinations in the names, it is all camel case. Agglutination in german is combining two words to a single one: e.g. "capital letter" becomes to "capitalletter".

    If you combine two nouns (fist letter in german is upper case) the fist letter of the second word becomes to lower case:

    Baum (tree) + Haus (house) => Baumhaus.

    That is the difference to camel case.

  • danman (unregistered)
       WRITE(6,*) 42HThis would never happen in FORTRAN77 since
       WRITE(6,*) 43HIt only allows 6 letters in a function name
       STOP
       END
    
  • (cs) in reply to Zoopaloola
    Zoopaloola:
    But German agglutination is so expressive and we really miss it in other languages ;-) But I do not see any agglutinations in the names, it is all camel case. Agglutination in german is combining two words to a single one: e.g. "capital letter" becomes to "capitalletter".

    If you combine two nouns (fist letter in german is upper case) the fist letter of the second word becomes to lower case:

    Baum (tree) + Haus (house) => Baumhaus.

    That is the difference to camel case.

    "Fist" letter?

    German agglutination, whatever that might be, is a decent stab (from the eighteen century) at ignoring latinate transgressions of the natural flow of the language.

    Unfortunately, that doesn't work too well, and hasn't since the eighteenth century.

    The (excellent) solution was to replace individual Latin words with the German equivalent -- thus, "umstand."

    Not, however, a natural way for a Germanic language to evolve, unless you happen to be a diplomat, or a literalist translator of the Bible, or some other sort of plonker.

    You need to examine Swedish.

    Now, there's the ideal of a Germanic language.

  • Zoopaloola (unregistered) in reply to real_aardvark

    Of course I meant "first". But misspelling it twice was consequential ;-)

  • pro (unregistered) in reply to Numeromancer

    gasp1!!!

  • (cs) in reply to Edward Royce
    Edward Royce:
    Sander Hoogendoorn:
    I've read carefully throughout all the comments on this peculiar post. Didn't anybody notice that the developers of this beautifully titled method aren't even aware of the abundant use of boolean logic in this code? Maybe it's because I'm a bit authistic, but if people write code like this:
    if (electionDate < DateTime.Today)
        {
            chkApplyUpdateToMainAndFutureRecords.Checked = false;
        }
        else
        {
            chkApplyUpdateToMainAndFutureRecords.Checked = true;
        }
    

    I just have to refactor it. Just can't leave this poor method like this. I would suggest the following line of code.

    chkApplyUpdateToMainAndFutureRecords.Checked = (electionDate < DateTime.Today);
    

    Hmmm.

    I'm probably wrong for doing this but I generally prefer to code the first way rather than the second. Mostly to ensure that the code is as obvious and explicit as possible. You can never tell who is going to replace you, or work with you, so I try to make code as idiot-proof as possible.

    Edward you are definitely wrong for doing that. If the idiot can't figure out what variable = expression means, why do you think he'll understand if(expression)?

    Sander please don't "refactor" code to do the EXACT opposite it did before.

  • joeybladb (unregistered)

    Is this the Diebold source code?

  • (cs)

    The scripting language in the PC game "Space Empires V" is even more atrocious... not only are the names horrendously long, but they're prefixed with "Sys" and words are delimited with underscores, e.g.

    Sys_Empire_Log_Get_Log_Entry_Message_Treaty_Elements

    (According to the documentation, this function "sets variables with the values of which players are participating in a treaty"...)

    One intrepid modder actually wrote a Perl script to parse the scripting docs (in PDF format!) and create aliases for the functions, so that you could call the above function as any of the following:

    SysEmpireLogGetLogEntryMessageTreatyElements - the "condensed" format Empire_Log_Get_Log_Entry_Message_Treaty_Elements - the "no Sys prefix format" EmpireLogGetLogEntryMessageTreatyElements - the "slightly resembling a real function name if there were only a '.' or '->' or something between EmpireLog and the rest to denote some sort of dereferencing" format!

  • IsThisTheDieboldSourceCode (unregistered) in reply to joeybladb

    Is this the Diebold source code?

  • (cs) in reply to iToad
    iToad:
    This sort of thing, and a lot of other WTFs, occur because it is simply too easy for anybody to write code.
    I dunno if it's that's necessarily the case. Microsoft has made it so that a CamelCasedFunction has a nicely formatted tooltip when you hover over it (and any other button or something assigned to run the function) - with the words separated, no less. It's a different sort of way to avoid writing comments, I suppose.
  • (cs) in reply to Sander Hoogendoorn
    Sander Hoogendoorn:
    I've read carefully throughout all the comments on this peculiar post. Didn't anybody notice that the developers of this beautifully titled method aren't even aware of the abundant use of boolean logic in this code? Maybe it's because I'm a bit authistic, but if people write code like this:
    if (electionDate < DateTime.Today)
        {
            chkApplyUpdateToMainAndFutureRecords.Checked = false;
        }
        else
        {
            chkApplyUpdateToMainAndFutureRecords.Checked = true;
        }
    

    I just have to refactor it. Just can't leave this poor method like this. I would suggest the following line of code.

    chkApplyUpdateToMainAndFutureRecords.Checked = (electionDate < DateTime.Today);
    

    You mean

    chkApplyUpdateToMainAndFutureRecords.Checked = electionDate >= DateTime.Today;
    
  • Joel (unregistered) in reply to Chucara
    Chucara:
    This is why I insist on a "Maximum 3 letters for function names" code standard.
    Ugh ... I hope you're not serious.

    Captcha: incassum (Inca's sum? Exactly how much gold do I win?)

  • tragomaskhalos (unregistered) in reply to Spectre
    Spectre:
    Okay, the real WTF(R) is migrating from VB .NET to C#. What's the point?
    Exactly. Presumably the same reason that C# even exists in the first place, ie purely for marketing reasons. Let's hope they at least used a sed script to do the "migration" !
  • Anonymous (unregistered)

    Heh, finally we get to audit the Diebold source code.

  • Blaze (unregistered)

    I prefer TalesFromTheLongMethodNameGenerator(int minLength)

  • NeoMojo (unregistered) in reply to Joel
    Joel:
    Chucara:
    This is why I insist on a "Maximum 3 letters for function names" code standard.
    Ugh ... I hope you're not serious.

    Of course he's serious (sorry if you're female Chucara, you're getting the default pronoun).

    3 letters is all you need. Give me one good example of when 3 letters isn't enough and I'll show you a pitching pony.

    And to those of you who think this is from Diebold's source - you're wrong. This is from your source code. The government controls how you vote.

  • rd (unregistered) in reply to joeybladb
    joeybladb:
    Is this the Diebold source code?
    See the FAQs.
  • Péter (unregistered) in reply to Anonymous Cow-herd
    Anonymous Cow-herd:
    Use of the m_ prefix combined with German-style agglutination - is this Austro-Hungarian Notation?

    Ja, az.

    Captcha: secundum.

  • Linus (unregistered) in reply to Harrow

    Now consider a recursive function.

  • Yoann (unregistered)

    Diebold, is that you?

  • Paul (unregistered)

    I hope that's not code from an electronic voting machine...

  • IUnknown (unregistered)

    This looks like a thing I had the unfortunate experience of being enslaved to called:

    AESM - Accenture Election Systems Management software.

    Tell me, is there a thing called the QueryBlock to be found in that code?

  • GeorgeSoros (unregistered)

    Damn, I pay off a bunch of so-called programmers to rig the election machines and they come up with crap like this? No wonder it didn't work!

  • bri3d (unregistered)

    Sony are still winners: A real psp library function: sceKernelLoadModuleBufferForLoadExecBufferVSHUsbWlanDebug also, sceNetAdhocTransferGetMallocStatParent they also name their different engines after subatomics and/or star trek: scePowerGetCurrentTachyonVoltage

Leave a comment on “TalesFromTheLongMethodNameGenerator(int maxLength)”

Log In or post as a guest

Replying to comment #:

« Return to Article