• Jerry Kindall (unregistered)

    Why, that's practically a Brazillian lines of code.

  • operagost (unregistered) in reply to Nicolas V.
    Nicolas V.:
    His PHP was very very basic and he never learned about the existence of SWITCH (which is a very universal mnemonic).
    Well, most BASICs use Select...Case.
  • BruteForce (unregistered)

    THIS would be MUCH better!

    MyValue = 0 ? &MyValue = MyValue : MyValue = 1 ? &MyValue = MyValue : MyValue = 2 ? &MyValue = MyValue : MyValue = 3 ? &MyValue = MyValue : MyValue = 4 ? &MyValue = MyValue : MyValue = 5 ? &MyValue = MyValue : MyValue = 6 ? &MyValue = MyValue : MyValue = 7 ? &MyValue = MyValue : break;

  • russell (unregistered)

    I suspect OCD.

  • KevinB (unregistered)

    Some others have noted above that it's possible the original code was written with the intent that the requirements would change for each value between 1 and 7.

    But surely a "Select Case" structure would have been more efficient?

  • Harrow (unregistered)

    This equivalent code is 16% shorter (and 50% narrower).

    Var MyTemp longint EndVar
      MyTemp = MyValue
      If MyTemp = 7
        MyTemp = 6
      EndIf
      If MyTemp = 6
        MyTemp = 5
      EndIf
      If MyTemp = 5
        MyTemp = 4
      EndIf
      If MyTemp = 4
        MyTemp = 3
      EndIf
      If MyTemp = 3
        MyTemp = 2
      EndIf
      If MyTemp = 2
        MyTemp = 1
      EndIf
      If MyTemp = 1
        MyTemp = 0
      EndIf
      If MyTemp = 0
        &MyValueDes = MyValueDes
      EndIf

    -Harrow.

  • iwan (unregistered) in reply to Trevel
    Trevel:
    I've seen worse.

    Take the same code and throw a

    For (MyValue==0;MyValue<=7;MyValue++)

    or whatever language equivalent around it and then you'll have REAL fun.

    You must be one of my coworkers then. I found exactly that during a review of some consultant's code the other day.

    The number was 30 instead of 7 though, and there were no else statements, so all conditions would be evaluated for every iteration.

  • darwin (unregistered) in reply to Nicolas V.
    Nicolas V.:
    His PHP was very very basic and he never learned about the existence of SWITCH (which is a very universal mnemonic).

    Am I the only one wondering what SWITCH is a mnemonic for?

    SWITCH Word Is The Crazy Heuristic

    And what about "very universal"? Is it possible to be more universal than ... universal? Once something is universal, isn't that pretty much it? Where do you go from there?

  • --PatF (unregistered)

    I think I have a better one. I once saw this in some VB code I was maintaining

    if (((VAL1=VAL2)=true)=true) then....

    Not a joke. We paid these guys $100.00 per hour for stuff like this.

    --PatF

  • Steve (unregistered)

    Could be FoxPro!

  • billyjoey (unregistered)

    dear god you guys laugh at that code then half of you cant write it better... my verison in vb: if (myValue <= 7) and (myValue >= 0) and (int(myValue) = myValue) then &MyValueDes = MyValueDes end if

    however my real question is what lanuage is this really, because in vb &MyValueDes = MyValueDes is redundent

  • qkxewudx (unregistered) in reply to Will

    boykbbyh http://gndwrkdc.com rkrwptny xsmbwfxg

  • ppzonlle (unregistered) in reply to Will

    mwarfnik http://pptbwnsd.com fxzuekyq gdfyrxcn

Leave a comment on “A Real Brazil Nut”

Log In or post as a guest

Replying to comment #:

« Return to Article