• H-Sphere Support (unregistered) in reply to Krenn
    Krenn:
    But just for dollars - in the US, the cent symbol is always placed afterward the number: 25¢.
    As is the pence symbol: 1p
  • secundum (unregistered) in reply to paddy
    Data Monkey:
    For consistency, I always iterate the results of a database query, even if I'm only expecting one row. For example, if there are three customers with the same customer ID, I ship an identical order to all three of them.

    What do you expect me to do? Randomly send everything to the first one? Design specs rarely address cases like this... (grumble...)

    ClaudeSuck.de:
    Zer0:
    BorisTheEngineer:
    kyle huff:
    Darkstar:
    paddy:
    Sextuple *whoosh*!

    You sir win teh internets

  • ClaudeSuck.de (unregistered) in reply to haha
    haha:
    ClaudeSuck.de:
    Data Monkey:
    For consistency, I always iterate the results of a database query, even if I'm only expecting one row. For example, if there are three customers with the same customer ID, I ship an identical order to all three of them.

    What do you expect me to do? Randomly send everything to the first one? Design specs rarely address cases like this... (grumble...)

    Three different customers with the same ID are a design spec??? What does the rest of the database look like?

    Specs:

    1. Customers need to have an identifier
    2. To save disk space please re-use existing identifiers
    3. Orders need to be sent to all customers with the same customer ID (3 customers = 3 sales/orders, hence $$$)

    CAPTCHA: ideo: I thought so, too

    The grass is greener on the other side, my billy goat friend - would you like to cross?

    =>You see a small path to the West and to the East. North is a bridge with a goat and a troll on it. What do you want to do?

  • Clint (unregistered)

    This is just an example of one of the more advanced design patterns.... The Batwing

  • Mike (unregistered)

    A little bit of work in proper indentation makes this much more workable..

    For Each LVMembCondItem In ListViewMemberCondition.ListItems
        TempDe1.InsertRule _
           AdvancedRule,                    "Advanced",
           Me.TextGroup,                    Me.CheckAutoApprove.Value, _
           CDate(Me.DTPickerFromDt),        CDate(Me.DTPickerToDt), ExpDate, _
           LVSvcItem.Text,                  LVSvcItem.ListSubItems(1).Text,
           LVDiagItem.Text,                 LVDiagItem.ListSubItems(1).Text,
           IIf( LVSvcItem.ListSubItems.Count = 1, "0", LVSvcItem.ListSubItems(LVSvcItem.ListSubItems.Count).Text ), _
           LVReqdSpecItem.Text,             LVReqdSpecItem.ListSubItems(1).Text, _
           LVReqdClassItem.Text,            LVReqdClassItem.ListSubItems(1).Text, _
           LVReqdContItem.Text,             LVReqdContItem.ListSubItems(1).Text, _
           LVReqdPayItem.Text,              LVReqdPayItem.ListSubItems(1).Text, _
           LVReqingSpecItem.Text,           LVReqingSpecItem.ListSubItems(1).Text, 
           LVReqingClassItem.Text,          LVReqingClassItem.ListSubItems(1).Text, _
           LVReqingContItem.Text,           LVReqingContItem.ListSubItems(1).Text, _
           LVReqingPayItem.Text,            LVReqingPayItem.ListSubItems(1).Text, _
           LVHPCodesItem.Text,              LVHPCodesItem.ListSubItems(1).Text, _
           LVPOSItem.Text,                  LVPOSItem.ListSubItems(1).Text, _
           LVReqdProvIDItem.Text,           LVReqdProvIDItem.ListSubItems(1).Text, _
           LVReqingProvIDItem.Text,         LVReqingProvIDItem.ListSubItems(1).Text, _
           TextDesc.Text,                   TextAgeFrom.Text, TextAgeTo.Text, _
           LVAuthTypeItem.Text,             LVAuthTypeItem.ListSubItems(1).Text, _
           LVMembCondItem.Text,             LVMembCondItem.ListSubItems(1).Text, _
           Me.cboRuleType.SelectedItem.Key, Me.txtRulePriority.Text, _
           Int(LVRefWarnItem.Text),         Int(LVRefWarnItem.ListSubItems(1).Text), _
           LVHPOptionCodesItem.Text,        LVHPOptionCodesItem.ListSubItems(1).Text
    Next
    

    Perhaps some macros (using a preprocessor like m4) would be of use.

    Legacy software can be fun, because there can be so many opportunities to improve (refactor) it.

  • ChrisH (unregistered)

    You lost me at For Each LVReqingContItem In Me.ListViewReqingCont.ListItems

    I mean you had me at hello. Sorry.

  • Keybounce (unregistered) in reply to Talking Head
    Talking Head:
    The problem is the two spaces indent. If you only use one space, it won't be nested nearly so deep.

    Mod parent up :-). Deserves to be a "featured" comment.

  • Keybounce (unregistered) in reply to Jasper
    Jasper:
    Beautiful code - ASCII art! ;-)

    Naah, real ascii art wins a C code contest. Didn't they have a flight simulator formatted to look like an airplane?

  • Lunkwill (unregistered) in reply to Mortal
    Mortal:
    I don't hope a single insertion takes as long as 0.1 seconds.
    If it includes a division[tm], then yes, it does.
  • MF (unregistered)

    O(n^18) ?

  • MF (unregistered) in reply to Data Monkey
    Data Monkey:
    For consistency, I always iterate the results of a database query, even if I'm only expecting one row. For example, if there are three customers with the same customer ID, I ship an identical order to all three of them.

    What do you expect me to do? Randomly send everything to the first one? Design specs rarely address cases like this... (grumble...)

    Uniqueness constraint? Maybe even a Primary Key?

  • John (unregistered)

    TRWTF [TM] is that he used spaces instead of tabs.

  • qbolec (unregistered) in reply to Placement officer
    Placement officer:
    daniel c w:
    So I am wondering: what should the creator of this code should have done instead?
    Grow roses.
    Great!
  • Tom (unregistered) in reply to steenbergh

    @steenbergh: Can you prove that the loop isn't infinite?

  • Hoodaticus (unregistered) in reply to Tom
    Tom:
    @steenbergh: Can you prove that the loop isn't infinite?

    I can.

  • Right Wing-Nut (unregistered)

    Well, the DWTF has just added a phrase to our lexicon here. A developer was commenting about how his test case had to essentially matrix the inputs to a function. My response? "Five is not eighteen."

  • eponymous cowherd (unregistered)

    Ack! My Eyes!

  • Gus (unregistered) in reply to MF

    The real WTF is the fact that none of you folks realized that this code is extremely fast most of the time. What do you think the chances are that normally at least one list is empty...

    I'm sure there was this one day when the server locked up for hours, but they never figured out why, and couldn't reproduce it after they rebooted.

    Or perhaps just one customer had repeated lock ups... (but that problem solved itself when they stopped being a customer)

  • Right Wing-Nut (unregistered) in reply to Gus
    Gus:
    The real WTF is the fact that none of you folks realized that this code is extremely fast most of the time. What do you think the chances are that normally at least one list is empty...

    I'm sure there was this one day when the server locked up for hours, but they never figured out why, and couldn't reproduce it after they rebooted.

    Or perhaps just one customer had repeated lock ups... (but that problem solved itself when they stopped being a customer)

    Actually, we were clued into that fact because the code in question did NOT take days to run. It does not matter. The code is an unmaintainable piece of ****, and whomever is responsible for it deserves punishment.

    The cool thing about this place is that if you actually bother to read the comments, there are usually some really good pointers made about what makes bad code so bad. This article has a couple.

  • Smart Ass (unregistered) in reply to jimlangrunner

    I always indent by three spaces. Of course, I always try to write sensible code, so yeah...

  • Eli Rabett (unregistered)

    The interesting question is whether it was ever executed. You could probably just dump the thing.

Leave a comment on “For The Love Of...”

Log In or post as a guest

Replying to comment #:

« Return to Article