• SR (unregistered) in reply to Right Wing-Nut
    Right Wing-Nut:
    Never mind that. To truly understand the significance of the code, you need to view it sideways. From one side, it is a bird of prey, screaming as it descends on your sanity. From the other, it is an alien invasion machine. You think you can disable it by uploading a virus, but if you do, the entire structure will collapse on your sanity.

    He's right. Look: v

  • ClaudeSuck.de (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...)

    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

  • daniel c w (unregistered) in reply to pitchingchris
    pitchingchris:
    The 58 arguments is definitely a WTF, and its a LOOOONG stretch that anybody realistically had to run the same function on all those collections.

    It may be too much, but we do not know for sure.

    Usually, when I read these pages I either immedeatly think of how it should have been done, or I see somebody else in the comments typing it out.

    I don't see any conext, that makes this code a WTF. Or is it obvious to anybody but me?

    So I am wondering: what should the creator of this code should have done instead?

  • ClaudeSuck.de (unregistered) in reply to kastein
    kastein:
    ... so that's 262.144 seconds and each one taking 0.1 seconds? or 0.100 seconds? is that equivalent to one tenth or one hundred?

    I know you crazy europeans use the decimal point as a thousands seperator as well as a radix point, but wtf? :P

    Nazi!

  • ClaudeSuck.de (unregistered) in reply to pitchingchris
    pitchingchris:
    The explanation is too freaking long to start

    Maybe you should structure your text (for example by indentations) so it will be easier to read.

  • (cs) in reply to kastein
    kastein:
    I know you crazy europeans use the decimal point as a thousands seperator as well as a radix point, but wtf? :P

    Crazy mainland Europeans. We, the UK, use a comma as the thousands separator and the full-stop as a radix separator.

    The weird arse notation confused me as well, then I realized they were probably from mainland Europe (or one of the other bits of the world that uses that notation).

    Oh and they use a comma as the radix separator, afaik.

  • (cs) in reply to ClaudeSuck.de
    ClaudeSuck.de:
    kastein:
    ... so that's 262.144 seconds and each one taking 0.1 seconds? or 0.100 seconds? is that equivalent to one tenth or one hundred?

    I know you crazy europeans use the decimal point as a thousands seperator as well as a radix point, but wtf? :P

    Nazi!

    Nah, they use the crazy notation too.

  • Yazeran (unregistered) in reply to Mortal
    Mortal:
    ClaudeSuck.de:
    Let one take 0.1 seconds then after some 7 hours your done saving them. Let there be one hour to choose the right combinations and you have WORKED AN ENTIRE DAY.

    I don't hope a single insertion takes as long as 0.1 seconds.

    Well with a function requiring 53 arguments a runtime of 0.1 seconds may not be too far off.

    Who knows what twisted logic resides inside THAT function. From what we can see here, the original coder may have been one of those who makes a new connection to the database for each iteration......

    Yours Yazeran

    Plan: To go to Mars one day with a hammer

  • blindman (unregistered)

    Why is bad code so pretty?

  • (cs) in reply to daniel c w
    daniel c w:
    I don't realy get the WTF, seriously

    Could somebody please explain?

    To quote Mr. Natural (of Zap Comics fame): "If you don't already know, don't mess with it."

  • (cs) in reply to mucki

    "O(n^^18), because sometimes P is almost NP :)"

    Maybe the coder was trying to prove P=NP by showing that P can become NP with enough code.

  • Numeromancer (unregistered) in reply to cod3_complete
    cod3_complete:
    Just take a fresh RAID can to these buggy apps and call it a day.

    RAID...Hmmm...

    That's it! A RAID array! That'll make my VB app run fast enough!

  • (cs) in reply to blindman
    blindman:
    Why is bad code so pretty?
    Evolution. Otherwise unfit code develops effective camouflage to conceal itself from predators.
  • PC Paul (unregistered) in reply to AdT
    AdT:
    Just my 0,02€.

    See, now you've lost me. I'm in the UK and thought I understood it both ways, but putting the € at the end? Followed by a decimal point? Or is that a centimal point to make the € into Euro-cents?

    As for the tiny font version, traditionally with microdot style information you have a prearranged place to put it so people know where to look. I suggest prefacing it with a colon and a dash, maybe?

    :->

  • Zer0 (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...)

    So you have a Customer ID... I may be confused but I thought ID was short for identification. Clearly this isn't the case with your database. Just an extra shiny number?

  • An Onymous (unregistered) in reply to Zer0
    Zer0:
    So you have a Customer ID... I may be confused but I thought ID was short for identification. Clearly this isn't the case with your database. Just an extra shiny number?
    Whoosh!
  • BorisTheEngineer (unregistered) in reply to 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...)

    Personally I would rather go with barfing noisily given that something must be seriously broken to get in this state and needs fixing (rather than than the company wondering a month or so later why they are shipping more orders than they are getting paid for and their being no useful information to give a clue where to start looking....)

    Oh, the fun of being on a support team with a 500 000+ lines of code and a problem report along the lines of "But it seems to give the wrong answer some of the time, but we're not sure when and can't reproduce it reliably."

  • AdT (unregistered) in reply to PC Paul
    PC Paul:
    See, now you've lost me. I'm in the UK and thought I understood it both ways, but putting the € at the end? Followed by a decimal point? Or is that a centimal point to make the € into Euro-cents?

    I'll never quite understand why English speakers like to put the currency symbol in front of the quantity. $5 is pronounced as "five dollars" after all, not "dollar five".

    Of course, writing 42 and saying "zweiundvierzig" (two and forty) doesn't make a lot of sense either. If I could redesign the German language, this would be high on my todo list. Right after changing the preferred numeral system to sexadecimal. Yes, sexadecimal. Portmanteaus of Latin and Greek words are supermoronic.

    PC Paul:
    As for the tiny font version, traditionally with microdot style information you have a prearranged place to put it so people know where to look. I suggest prefacing it with a colon and a dash, maybe?

    :->

    I have no idea what you're referring to, but this looks like a vampire who lost his lower jaw: :-€

    Nowadays the spelling "vampyre" is much more fashionable though. Vampyres are much more evyl and vycious than vampires.

  • Adam (unregistered) in reply to Cro

    yeah, the logic is ridiculous, but at least we can SEE that the logic is ridiculous. Imagine that with no white space... I'm maintaining a project right now where the previous developer must have thought that 'TAB' was only a beverage.

  • Tama (unregistered) in reply to Zylon
    Zylon:
    blindman:
    Why is bad code so pretty?
    Evolution. Otherwise unfit code develops effective camouflage to conceal itself from predators.

    Awaesome. Just awesome.

  • Krenn (unregistered) in reply to AdT
    AdT:
    PC Paul:
    See, now you've lost me. I'm in the UK and thought I understood it both ways, but putting the € at the end? Followed by a decimal point? Or is that a centimal point to make the € into Euro-cents?

    I'll never quite understand why English speakers like to put the currency symbol in front of the quantity. $5 is pronounced as "five dollars" after all, not "dollar five".

    But just for dollars - in the US, the cent symbol is always placed afterward the number: 25¢.

  • Apocrypha (unregistered) in reply to Krenn

    That works out fine unless you're an American cell phone provider in which case 0.01¢ means to them 1 cent and you realize everything is broken.

  • kyle huff (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...)

    How about a Primary Key constraint? Srsly, WTF dude.

  • Anon (unregistered)

    Its not an O(n^18) algorithm, but rather an O(abcdefghijklmnopq) algorithm, or more succinctly described as O(mygod). Isn't that just adorable.

  • Brent (unregistered)

    Hmmm... maintaining legacy software seems like it would be a punishment for writing unmaintainable code. That sin is at least 5th circle (if done because you're lazy)... which is outside of Dis, but just barely. If you consciously do it, then it's either circle 8 (if done to make yourself indispensable) or circle 9 (if done to sabotage).

  • Darkstar (unregistered) in reply to 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.
    If the database constraints dictate that there can be no more than one row for each id, you're solving non-existent problems there. Not as bad as double checking that 2 + 2 = 4, but well underway.
  • (cs) 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...)

    You sir, are either the product of an overabundance of profoundly poor whiskey, or a blatant troll who is just a little to obvious.

    I find it hard to believe you could possible defend:

    1. Iterating over multiple rows when you expect one, and thus unexpectedly duplicating shipped orders is a graceful way to handle unexpected duplicate customers.
      ...either that is the poorest form of 'error handling' imaginable, or the poorest planning of a 'customer group order splitting' feature ever conceived.

    2. Calling something an 'ID' when it does not in fact uniquely identify anything. How do you actually identify which customer actually ordered something if you have duplicate IDs? If you are certain they are all the same customer somehow - how do you know which row of customer data has the most current data for that customer?

    Either you are a troll, or a ditch digger yet to discover his true calling in life.

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

    WTF???

  • Pedantic Fuck (unregistered) in reply to ClaudeSuck.de
    ClaudeSuck.de:
    Mortal:
    ClaudeSuck.de:
    Let one take 0.1 seconds then after some 7 hours your done saving them. Let there be one hour to choose the right combinations and you have WORKED AN ENTIRE DAY.

    I don't hope a single insertion takes as long as 0.1 seconds.

    I hope there are only 2 possibilities for each. What about 3^^18 or 4^^18 (or n^^18) given that they are all list views?

    Except....n**x is denoted n^x. n^^x is more commonly used in math (or at least Math Computing) to represent (n^x)^x (which is a little bit worse than I think this code is)

  • haha (unregistered) in reply to ClaudeSuck.de
    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?

  • haha (unregistered) in reply to Zer0
    Zer0:
    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...)

    So you have a Customer ID... I may be confused but I thought ID was short for identification. Clearly this isn't the case with your database. Just an extra shiny number?

    A second Billy Goat stepped onto the bridge, only to be met by a hungry troll.

  • haha (unregistered) in reply to BorisTheEngineer
    BorisTheEngineer:
    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...)

    Personally I would rather go with barfing noisily given that something must be seriously broken to get in this state and needs fixing (rather than than the company wondering a month or so later why they are shipping more orders than they are getting paid for and their being no useful information to give a clue where to start looking....)

    Oh, the fun of being on a support team with a 500 000+ lines of code and a problem report along the lines of "But it seems to give the wrong answer some of the time, but we're not sure when and can't reproduce it reliably."

    And we have all three!!!

  • Jumbo (unregistered) in reply to AdT
    AdT:
    PC Paul:
    See, now you've lost me. I'm in the UK and thought I understood it both ways, but putting the € at the end? Followed by a decimal point? Or is that a centimal point to make the € into Euro-cents?

    I'll never quite understand why English speakers like to put the currency symbol in front of the quantity. $5 is pronounced as "five dollars" after all, not "dollar five".

    Of course, writing 42 and saying "zweiundvierzig" (two and forty) doesn't make a lot of sense either. If I could redesign the German language, this would be high on my todo list. Right after changing the preferred numeral system to sexadecimal. Yes, sexadecimal. Portmanteaus of Latin and Greek words are supermoronic.

    PC Paul:
    As for the tiny font version, traditionally with microdot style information you have a prearranged place to put it so people know where to look. I suggest prefacing it with a colon and a dash, maybe?

    :->

    I have no idea what you're referring to, but this looks like a vampire who lost his lower jaw: :-€

    Nowadays the spelling "vampyre" is much more fashionable though. Vampyres are much more evyl and vycious than vampires.

    English used to be a bit backward with numbers too (they sort of still are with teens - although many languages are...The half-exception that immediately springs to mind is italian, which counts through 11 (undici) to 16 (sedici) with the smaller value prefixing and then swaps for 17 (diciasette), 18 (diciotto), and 19 (dicianove))

    An English example: "Sing a song of sixpence a pocket full of rye, Four and twenty blackbirds baked in a pie."

  • haha (unregistered) in reply to kyle huff
    kyle huff:
    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...)

    How about a Primary Key constraint? Srsly, WTF dude.

    My Goodness, nbow we have too many Billy-Goats

  • haha (unregistered) in reply to Darkstar
    Darkstar:
    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.
    If the database constraints dictate that there can be no more than one row for each id, you're solving non-existent problems there. Not as bad as double checking that 2 + 2 = 4, but well underway.

    Goat's Cheese, anyone?

  • (cs) in reply to Jumbo
    Jumbo:
    An English example: "Sing a song of sixpence a pocket full of rye, Four and twenty blackbirds baked in a pie."
    "Four score and seven years ago our fathers brought forth on this continent a new nation..."
  • Hoodaticus (unregistered)

    Loops like violence

  • Hoodaticus (unregistered)

    He obviously isn't sending triple orders. He was making a subtle, funny point.

  • Hoodaticus (unregistered)

    I just had a disturbing thought: just imagine what the insides of the InsertRule method look like!

    CAPTCHA: delenit - the act of nulling a string.

  • (cs) in reply to daniel c w
    daniel c w:
    pitchingchris:
    The 58 arguments is definitely a WTF, and its a LOOOONG stretch that anybody realistically had to run the same function on all those collections.

    It may be too much, but we do not know for sure.

    Usually, when I read these pages I either immedeatly think of how it should have been done, or I see somebody else in the comments typing it out.

    I don't see any conext, that makes this code a WTF. Or is it obvious to anybody but me?

    So I am wondering: what should the creator of this code should have done instead?

    Well without the spec, we don't know if this code is a true WTF (but seriously, 57 argument function? or however many that is)

    Without knowing the context, do you really think that for every RefWarnItem you need to iterate over everything else? These are listview items, so chances are you only need to look at one item for each listview control. What about the fact that he passes in LVSvcItem.ListSubItems(1).Text, then does an IFF(LVSvcItem.ListSubItems.Count == 1) Can LVSvcItem.ListSubItems have 0 items? What happens if it has 2, we always pass the first item in.

    Without knowing the context, I can tell you that if you are nesting 18 levels of "foreach" you should probably be rethinking your design.

  • Data Monkey (unregistered) in reply to paddy
    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...)

    You sir, are either the product of an overabundance of profoundly poor whiskey, or a blatant troll who is just a little to obvious.

    Not obvious enough, methinks, based on how many fish I caught.

    Oh, and I think you meant "too obvious". But I realize English is difficult as a second language.

  • (cs) in reply to aaberg
    aaberg:
    Just looking at this code, makes my head hurt!!

    At least it is indented nicely. Many years ago, I worked as an Oracle DBA on a project, and there were always a PL/SQL package that was a nightmare to compile.

    6 months later, I was hired as a developer to maintain those packages and the VB app that used them. The prince of insufficient light must have really been busy that day.

    This code was thousands of lines long. After indenting it myself, it looked like the Code SOD, but with many more lines and recursive function calls.

    Even finding the query was a major project. By the time I was done, I figured it:

    1. Ran the database query
    2. Saved the x/y coordinates and font sizes of the output in a different table, so if the query was ran later the original formatting would be preserved, even though the query results might be different.

    After removing the Cartesian product from the query, I put the query directly in the VB code and used a VB control to save the printed windows meta file in a LONG RAW column in the database, so the same report could be printed later exactly.

    My favorite part of this was submitting a change request to my DBA friends for the PL/SQL package, wording like any other, expecting them to groan as we always did, and then to see the look on their faces when the request said:

    "please drop package xxxx from the database and remove it from all CM repositorues"

  • josey wales (unregistered)

    Speaking of outstanding encapsulation, I have some CAM software here that we use to generate G-code for a cabinet shop CNC router. This (obviously) VB6 app uses .mdb for its backing store, and poking around in some the libraries it registered on the machine generally yields things like this:

    Function WritePartRecord(
      ByVal psRecordName As String, 
      ByVal psMatDescription As String,   
      ByVal psXDim As String, 
      ByVal psYDim As String, 
      ByVal psZDim As String, 
      ByVal psQty As String, 
      ByVal psRecordDescription As String, 
      ByVal psIgnorePanel As String, 
      ByVal psBackSide As String, 
      ByVal psLabel1 As String, 
      ByVal psLabel2 As String, 
      ByVal psLabel3 As String, 
      ByVal psLabel4 As String, 
      ByVal psVarCount As String, 
      ByVal psDOITFilePrimary As String, 
      ByVal psDOITFileSecondary As String, 
      ByVal psKnowDrawPrim As String, 
      ByVal psKnowDrawSec As String, 
      ByVal psPostPrim As String, 
      ByVal psPostSec As String, 
      ByVal psRotate As String, 
      ByVal psRotateAngle As String, 
      ByVal psConcatName As String, 
      ByVal psPartGUID As String, 
      ByVal psStartPointLong As String, 
      ByVal psCNCFileNameNest As String, 
      ByVal psCNCFileNameSinglePart As String) As Boolean
        Member of [namespace removed].clsGenPRN
    
    

    WritePartRecord. So close, yet so far.

    btw, this particular software goes for about 8K USD, is usually packaged with a new machine, and as such, is likely used to generate code for somewhere around a billion dollars-worth of CNC routers. The amazing part is that as buggy as the gui is, the code it generates is has always been pretty much flawless. Go figure.

  • (cs) in reply to Jumbo
    Jumbo:
    An English example: "Sing a song of sixpence a pocket full of rye, Four and twenty blackbirds baked in a pie."
    Mmm pie!
  • burpy (unregistered) in reply to hikari
    hikari:
    ClaudeSuck.de:
    kastein:
    ... so that's 262.144 seconds and each one taking 0.1 seconds? or 0.100 seconds? is that equivalent to one tenth or one hundred?

    I know you crazy europeans use the decimal point as a thousands seperator as well as a radix point, but wtf? :P

    Nazi!

    Nah, they use the crazy notation too.

    No no they don't use any separators, they prune...

  • Mike5 (unregistered) in reply to BillyD
    BillyD:
    Brillant!!
    TFTFY

    Mike5

  • MadCow (unregistered) in reply to Hash Cash
    Hash Cash:
    ubersoldat:
    the 53 arguments function... priceless
    Whenever you see a function with more than about 8 args, it is time to rethink your design -- maybe a global hash, so you don't have to keep passing all that data back and forth.

    Obviously, you should be passing a single structure as the argument -- a 53-member structure, that is.

  • (cs) in reply to chrismcb
    chrismcb:
    daniel c w:
    pitchingchris:
    The 58 arguments is definitely a WTF, and its a LOOOONG stretch that anybody realistically had to run the same function on all those collections.

    It may be too much, but we do not know for sure.

    Usually, when I read these pages I either immedeatly think of how it should have been done, or I see somebody else in the comments typing it out.

    I don't see any conext, that makes this code a WTF. Or is it obvious to anybody but me?

    So I am wondering: what should the creator of this code should have done instead?

    Well without the spec, we don't know if this code is a true WTF (but seriously, 57 argument function? or however many that is)

    Without knowing the context, ... <snip>

    Without knowing the context, I can tell you that if you are nesting 18 levels of "foreach" you should probably be rethinking your design.

    It's called a "Code Smell". Any decent developer instinctively knows something is wrong. Proposing a solution is a whole different game.

  • Jasper (unregistered)

    Beautiful code - ASCII art! ;-)

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

Log In or post as a guest

Replying to comment #:

« Return to Article