• (cs)

    Well, to me it just looks as if the dll in question were called by some VBScript from an ASP page. What's wrong with that?

    It might look a little unwieldy, but would you rather make 1 insert call and a lot of update calls or maybe pass an array of unchecked values down to the database level?

    (I am fairly sure that objects (like real Objects) were out of the question at the time.)

    (second attempt)

  • CGoetz (unregistered) in reply to dsckeld

    This function definition looks so horrible, I believe I have eye cancer from looking at it.

    As a member of the clean code movement here in germany, I can only strong advise a refactoring of this beast.

    Or if it is a sealed dll: Write an adaptor against it and use your own functions instead, this will make the code mich better on your side.

  • anonymouse (unregistered)

    I have similar problems. Imagine the same kind of architecture... but written in the sloppiest spaghettiest PHP you've ever seen.. by the manager (we are not a software house, so the manager isn't/wasn't a programmer). That's what I get to maintain.

  • Spivonious (unregistered)

    The code looks very enterprisey.

  • Shai (unregistered) in reply to dsckeld
    dsckeld:

    It might look a little unwieldy, but would you rather [...] pass an array of unchecked values down to the database level?

    Unchecked, as opposed to all of them declared Variant?

  • frits (unregistered)

    Stack overflow at line 0.

  • - (unregistered) in reply to Spivonious
    Spivonious:
    The code looks very enterprisey.

    Why tie yourself to inflexible variable names? Why specify variant when that can be implied? 'Guru' coder also spots the pointless 'byVal' call on a reference type and eliminates this redundancy...

    ...So this is even more enterprisey:

    Public Function InsertXMLShipment(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,ll,mm,nn,oo) As Boolean

    I'm sure you would agree this is a MUCH better approach

  • Harrow (unregistered) in reply to CGoetz
    CGoetz:
    ...Write an adaptor against it and use your own functions instead, this will make the code mich better on your side.
    Isn't that how the current architecture came into existence in the first place? As described, it sounds exactly like layer after layer of wrappers and adaptors written by a succession of developers each trying to make his own code mich better on his side.

    -Harrow.

  • (cs)
    fShpCarPieces As Variant
    I remember that episode of M*A*S*H...
  • (cs)

    The only problem with the "representative line" is the fact that they are all variants, strongly type them.

    If you complain about the number of arguments, make a structure (oh VB6, make a Type) and simply pass a variable of that structure, there you go, one parameter that holds all those values.

  • Daniil (unregistered)

    That looks about right. We got plenty of those kinds of methods written in both VB and Java. Debugging that and adding new things is just a delight. They should really teach that in schools. Its so easy to manage that kind of code.

  • Daniil (unregistered) in reply to -

    Ha! +1 on this one. I'm bored.

  • frits (unregistered) in reply to KattMan
    KattMan:
    The only problem with the "representative line" is the fact that they are all variants, strongly type them.

    If you complain about the number of arguments, make a structure (oh VB6, make a Type) and simply pass a variable of that structure, there you go, one parameter that holds all those values.

    So replace "Long Parameter List" code smell with a variation of the "Large Class" smell. Why not just declare a bunch of global variables and refactor with the "accumulate and fire" anti-pattern ?

  • Rodnas (unregistered)

    It burns my eyes AND o my god, the humanity

  • (cs) in reply to frits
    frits:
    So replace "Long Parameter List" code smell with a variation of the "Large Class" smell. Why not just declare a bunch of global variables and refactor with the "accumulate and fire" anti-pattern ?
    Awww cute, someone just read that refactoring book.
  • Bim Job (unregistered) in reply to Harrow
    Harrow:
    CGoetz:
    ...Write an adaptor against it and use your own functions instead, this will make the code mich better on your side.
    Isn't that how the current architecture came into existence in the first place? As described, it sounds exactly like layer after layer of wrappers and adaptors written by a succession of developers each trying to make his own code mich better on his side.

    -Harrow.

    For some reason, this reminds me of the Last Goon Show of All:

    Bluebottle: Eccles! Turn the knob on your side! Eccles: I haven't got a knob on my side.

    This ... thing ... is way beyond refactoring. It's like senile dementia from a junior programmer: open your mouth, and just start babbling whatever comes in to your head.

    One thing bothers me, though: the function name. What on earth is InsertXMLShipment all about? Is it now a mandatory requirement for every enterprisey solution to include "XML" in the function name, as well as the architecture? Or has the company in question given up entirely on shipping actual physical items, and gone down the underpants ... XML ... profit route of shipping bags o' bytes instead?

  • cromar (unregistered)

    That's no moon!

  • Anynomous Coward (unregistered)

    /me wonders where the inputs are(n't?) sanitized at?

  • Mortal (unregistered)

    Shipping-related fields... table with almost one-to-one equivalency... and somehow, somewhere, XML is inserted?

  • (cs)

    If I remember right, ASP (VB6 style) all variables are variants, so any VB6 interfaces have to define variable as variants.

    That being said, passing a string of XML would be better, but the variants are not the WTF.

  • frits (unregistered) in reply to Zylon
    Zylon:
    frits:
    So replace "Long Parameter List" code smell with a variation of the "Large Class" smell. Why not just declare a bunch of global variables and refactor with the "accumulate and fire" anti-pattern ?
    Awww cute, someone just read that refactoring book.

    Awww cute, someone's sticking up for his pal.

  • (cs)

    The real Matryoshka Method is to stick everything inside an .MKV file.

  • Bim Job (unregistered) in reply to frits
    frits:
    Zylon:
    frits:
    So replace "Long Parameter List" code smell with a variation of the "Large Class" smell. Why not just declare a bunch of global variables and refactor with the "accumulate and fire" anti-pattern ?
    Awww cute, someone just read that refactoring book.

    Awww cute, someone's sticking up for his pal.

    Awww, cute, someone's decided to duck the issue via an ad hominem attack.

    Only a god-damn lunatic would replace seventeen function parameters with global variables in the middle of DLL hell.

    Refactoring is designed, if that is the word, to accommodate changes in specification and/or cleanups after the proverbial death march.

    This "code" does not need refactoring. It cries out for replacing.

  • frits (unregistered) in reply to Bim Job
    Bim Job:
    frits:
    Zylon:
    frits:
    So replace "Long Parameter List" code smell with a variation of the "Large Class" smell. Why not just declare a bunch of global variables and refactor with the "accumulate and fire" anti-pattern ?
    Awww cute, someone just read that refactoring book.

    Awww cute, someone's sticking up for his pal.

    Awww, cute, someone's decided to duck the issue via an ad hominem attack.

    Only a god-damn lunatic would replace seventeen function parameters with global variables in the middle of DLL hell.

    Refactoring is designed, if that is the word, to accommodate changes in specification and/or cleanups after the proverbial death march.

    This "code" does not need refactoring. It cries out for replacing.

    Does your brain work properly? Do you think calling something an "anti-pattern" is an endorsement?

    Bad code is bad.

  • LongCat (unregistered) in reply to frits
    frits:
    Bim Job:
    frits:
    Zylon:
    frits:
    So replace "Long Parameter List" code smell with a variation of the "Large Class" smell. Why not just declare a bunch of global variables and refactor with the "accumulate and fire" anti-pattern ?
    Awww cute, someone just read that refactoring book.

    Awww cute, someone's sticking up for his pal.

    Awww, cute, someone's decided to duck the issue via an ad hominem attack.

    Only a god-damn lunatic would replace seventeen function parameters with global variables in the middle of DLL hell.

    Refactoring is designed, if that is the word, to accommodate changes in specification and/or cleanups after the proverbial death march.

    This "code" does not need refactoring. It cries out for replacing.

    Does your brain work properly? Do you think calling something an "anti-pattern" is an endorsement?

    Bad code is bad.

    And Long Cat is Long!!

    (sorry, couldn't resist....)

  • Bim Job (unregistered) in reply to frits
    frits:
    Bim Job:
    frits:
    Zylon:
    frits:
    So replace "Long Parameter List" code smell with a variation of the "Large Class" smell. Why not just declare a bunch of global variables and refactor with the "accumulate and fire" anti-pattern ?
    Awww cute, someone just read that refactoring book.

    Awww cute, someone's sticking up for his pal.

    Awww, cute, someone's decided to duck the issue via an ad hominem attack.

    Does your brain work properly? Do you think calling something an "anti-pattern" is an endorsement?

    Bad code is bad.

    I'm sorry, I must have mistaken your comment (in bold) for some sort of offensive brain-damaged response to another poster.

    My mistake. Given that assumption, it seems entirely reasonable to assume that you meant to endorse an "anti-pattern."

  • frits (unregistered) in reply to Bim Job

    Way to cut out your diatribe about "global variables" and such. It is ironic that you accuse me of ad hominem attack, when that what provoked my "brain-damaged response" to antoher poster. Why do you care anyway? Troll much? Oh, and apology accepted.

  • hoodaticus (unregistered)

    That is the ugliest function signature I have ever seen. It's infectiously ugly. Even without the article, you know its nastiness must have transmitted and promulgated itself throughout the surrounding system like a virus.

    Dust off and nuke it from orbit. It's the only way to be sure.

  • hoodaticus (unregistered) in reply to frits
    frits:
    Stack overflow at line 0.
    Frits makes me laugh every time! Heaven forbid this monster be recursive...
  • hoodaticus (unregistered) in reply to KattMan
    KattMan:
    The only problem with the "representative line" is the fact that they are all variants, strongly type them.

    If you complain about the number of arguments, make a structure (oh VB6, make a Type) and simply pass a variable of that structure, there you go, one parameter that holds all those values.

    VB6 has classes bra. The huge number of arguments is a giant cluebat that the coder was clueless.

  • (cs)
       HTML
       | ^
       v |
       ???????
       | ^
       v |
       XML
       | ^
       v |
       SOAP 
       | ^
       v |
       ??????
       | ^
       v |
       VB6.EXE (service)
       | ^
       v |
       VB6.DLL
       | ^
       v |
       VB6.DLL
       | ^
       v |
       Stored Procedure
       | ^
       v |
       Stored Procedure
       | ^
       v |
       More Stored Procedures
       | ^
       v |
       SQL Insert
       | ^
       v |
       Table
    
    

    Gee...and then we wonder why we need EHz processors to see a cat jump in a box and fall over.

  • hoodaticus (unregistered)

    LOL- with all those arguments, this "function" returns what for error information? A Boolean.

  • (cs)

    Maybe the developers wanted to get "n-tier architecture" on their resumes.

  • hoodaticus (unregistered) in reply to Tzimisce

    With that handle, do you play Bloodlines?

  • (cs) in reply to hoodaticus
    hoodaticus:
    LOL- with all those arguments, this "function" returns what for error information? A Boolean.

    Yeah, but how many different values can a microsoft boolean have? I know its more than two.

  • foxyshadis (unregistered) in reply to coyo
    coyo:
    hoodaticus:
    LOL- with all those arguments, this "function" returns what for error information? A Boolean.

    Yeah, but how many different values can a microsoft boolean have? I know its more than two.

    A BOOL is just an int. But a VB Boolean is a real bool, there's no way to assign anything else to it without casting it to Variant.

  • (cs) in reply to foxyshadis
    foxyshadis:
    coyo:
    hoodaticus:
    LOL- with all those arguments, this "function" returns what for error information? A Boolean.

    Yeah, but how many different values can a microsoft boolean have? I know its more than two.

    A BOOL is just an int. But a VB Boolean is a real bool, there's no way to assign anything else to it without casting it to Variant.

    Clearly the sane thing to do is to change the return value from Boolean to Variant.

  • Some Wonk (unregistered) in reply to LongCat
    LongCat:
    frits:
    Bim Job:
    frits:
    Zylon:
    frits:
    So replace "Long Parameter List" code smell with a variation of the "Large Class" smell. Why not just declare a bunch of global variables and refactor with the "accumulate and fire" anti-pattern ?
    Awww cute, someone just read that refactoring book.

    Awww cute, someone's sticking up for his pal.

    Awww, cute, someone's decided to duck the issue via an ad hominem attack.

    Only a god-damn lunatic would replace seventeen function parameters with global variables in the middle of DLL hell.

    Refactoring is designed, if that is the word, to accommodate changes in specification and/or cleanups after the proverbial death march.

    This "code" does not need refactoring. It cries out for replacing.

    Does your brain work properly? Do you think calling something an "anti-pattern" is an endorsement?

    Bad code is bad.

    And Long Cat is Long!!

    (sorry, couldn't resist....)

    And Leon is getting larger...

  • Richard (unregistered)

    So, was anyone tempted to click the "Hear a Blog" link for more comic relief?

  • Shriike (unregistered)

    I'm just curious. I had a similar problem to tackle, and I don't think my solution was really any better. (I passed in an array of strings for the variables, and an array of strings for names of variables). While I'm aware this probably isn't an ideal solution. I do wonder, what is?

    Someone suggested building a class, but that seems kind of dumb to me, the constructor would be just as unwieldy and each attribute would have to be referenced individually, so surely there is a better solution to this, right?

    Captcha: nisl, I think it's like a missile?

  • Katana (unregistered) in reply to Shriike
    Shriike:
    Someone suggested building a class, but that seems kind of dumb to me, the constructor would be just as unwieldy and each attribute would have to be referenced individually, so surely there is a better solution to this, right?

    Yes, but in VB you could make it very clear as in dim x as new XMLShipment() WITH x .Property1="whatever" .SomeOtherBit = "dude" .FileNotFound = IsBooleanTrue(false) END WITH

    and it would be very clear to someone who later had to read the code what you were stuffing all those values into, as opposed to just having 40 lines of code setting values that have no obvious relationship to one another.

  • iToad (unregistered) in reply to hoodaticus
    hoodaticus:
    frits:
    Stack overflow at line 0.
    Frits makes me laugh every time! Heaven forbid this monster be recursive...

    Some people thought that the LHC was going to generate some sort of mini black hole which would destroy the earth. If you called this thing recursively, it could actually happen.

  • BCS (unregistered)

    I think I spotted a typo; the "pmen" in the function name should be removed.

  • SomeCoder (unregistered) in reply to Some Wonk
    Some Wonk:
    And Leon is getting larger...

    WIN. This comment is just full of WIN.

  • hoodaticus (unregistered) in reply to Shriike
    Shriike:
    I'm just curious. I had a similar problem to tackle, and I don't think my solution was really any better. (I passed in an array of strings for the variables, and an array of strings for names of variables). While I'm aware this probably isn't an ideal solution. I do wonder, what is?

    Someone suggested building a class, but that seems kind of dumb to me, the constructor would be just as unwieldy and each attribute would have to be referenced individually, so surely there is a better solution to this, right?

    Captcha: nisl, I think it's like a missile?

    I'm not sure what you're trying to do, but it sounds perfectly okay to me, although you may want to research the Collection object, using one array for the "names of variables" / keys and a Collection object to store the data itself. This will let you retrieve data by string key without having to array scan the variable names yourself with every access. There are advantages and disadvantages to using VB Collections that I won't go into, and the solution you already have is likely to be optimum if there are fewer than, say, a hundred variables in the array to scan.

    What the OP's WTFer did - storing the raw data on the stack as a huge number of arguments to a function - is a WTF. The whole thing comes crashing down if you run out of stack space. And what happens if he has to add new data to insert/update? Oh well, re-write the function! Using a few classes would let the system be much more flexible than this trainwreck. If the OP's WTFer was using OOP all along, then he never would have amassed 17 arguments in a function... his solution would have tended towards much more elegance.

    It sounds like you are passing two array references and maybe a couple other arguments into a function. Without knowing what your problem is, the way you are doing it now sounds perfect and by no means a WTF.

  • hoodaticus (unregistered) in reply to Bacon Bits
    Bacon Bits:
    Clearly the sane thing to do is to change the return value from Boolean to Variant.

    ZOMG LOL!

  • Quirkafleeg (unregistered) in reply to Shriike
    Shriike:
    Captcha: nisl, I think it's like a missile?
    Only if you've poked one of its ‘I’s out.
  • (cs) in reply to Tzimisce
    Tzimisce:
    Maybe the developers wanted to get "n-tier architecture" on their resumes.

    Hey, can I get an n-tier architecture on my resume with this?

      static boolean equal(int a, int b)
      {
          int tiers = 100;
          int tier_a[] = new int[tiers];
          int tier_b[] = new int[tiers];
          boolean tier_r[] = new boolean[tiers];
          tiers--;
    
          tier_a[0] = a;
          tier_b[0] = b;
    
          for (int j = 0; j < tiers; j++)
          {
              tier_a[j+1] = tier_a[j];
              tier_b[j+1] = tier_b[j];
          }
    
          tier_r[tiers] = (tier_a[tiers] == tier_b[tiers]);
    
          for (int j = tiers; j > 0; j--)
          {
              tier_r[j-1] = tier_r[j];
          }
          
          return tier_r[0];
       }
    
    

    "My tiers are deeper than your tiers!"

    Addendum (2009-12-21 19:06): Sorry, after writing this, the old "Ken-L Ration" ditty popped into my head and I just had to...

    "My tiers are deeper than your tiers." "My tiers are deeper than yours!" "My tiers are deepest 'cause they've got SOAP in them!" "My tiers are deeper than yours!"

  • (cs)

    One of the few articles that actually made me ask WTF out loud.

  • Hot Shot (unregistered) in reply to Quirkafleeg

    My eye!

Leave a comment on “The Matryoshka Method”

Log In or post as a guest

Replying to comment #293873:

« Return to Article