| « Prev | Page 1 | Page 2 | Next » |
|
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) |
Re: The Matryoshka Method
2009-12-21 09:57
•
by
CGoetz
(unregistered)
|
|
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. |
|
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.
|
|
The code looks very enterprisey.
|
Re: The Matryoshka Method
2009-12-21 10:08
•
by
Shai
(unregistered)
|
Unchecked, as opposed to all of them declared Variant? |
|
Stack overflow at line 0.
|
Re: The Matryoshka Method
2009-12-21 10:26
•
by
-
(unregistered)
|
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 |
Re: The Matryoshka Method
2009-12-21 10:31
•
by
Harrow
(unregistered)
|
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. |
fShpCarPieces As VariantI remember that episode of M*A*S*H... |
|
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. |
|
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.
|
Re: The Matryoshka Method
2009-12-21 10:59
•
by
Daniil
(unregistered)
|
|
Ha! +1 on this one. I'm bored.
|
Re: The Matryoshka Method
2009-12-21 11:03
•
by
frits
(unregistered)
|
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 ? |
|
It burns my eyes AND o my god, the humanity
|
Awww cute, someone just read that refactoring book. |
Re: The Matryoshka Method
2009-12-21 11:27
•
by
Bim Job
(unregistered)
|
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? |
|
That's no moon!
|
|
/me wonders where the inputs are(n't?) sanitized at?
|
|
Shipping-related fields... table with almost one-to-one equivalency... and somehow, somewhere, XML is inserted?
|
|
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. |
Re: The Matryoshka Method
2009-12-21 12:22
•
by
frits
(unregistered)
|
Awww cute, someone's sticking up for his pal. |
|
The real Matryoshka Method is to stick everything inside an .MKV file.
|
Re: The Matryoshka Method
2009-12-21 12:30
•
by
Bim Job
(unregistered)
|
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. |
Re: The Matryoshka Method
2009-12-21 12:38
•
by
frits
(unregistered)
|
Does your brain work properly? Do you think calling something an "anti-pattern" is an endorsement? Bad code is bad. |
Re: The Matryoshka Method
2009-12-21 12:54
•
by
LongCat
(unregistered)
|
And Long Cat is Long!! (sorry, couldn't resist....) |
Re: The Matryoshka Method
2009-12-21 13:02
•
by
Bim Job
(unregistered)
|
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." |
Re: The Matryoshka Method
2009-12-21 13:18
•
by
frits
(unregistered)
|
|
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.
|
|
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. |
Re: The Matryoshka Method
2009-12-21 13:29
•
by
hoodaticus
(unregistered)
|
Frits makes me laugh every time! Heaven forbid this monster be recursive... |
Re: The Matryoshka Method
2009-12-21 13:36
•
by
hoodaticus
(unregistered)
|
VB6 has classes bra. The huge number of arguments is a giant cluebat that the coder was clueless. |
Gee...and then we wonder why we need EHz processors to see a cat jump in a box and fall over. |
|
LOL- with all those arguments, this "function" returns what for error information? A Boolean.
|
|
Maybe the developers wanted to get "n-tier architecture" on their resumes.
|
Re: The Matryoshka Method
2009-12-21 14:25
•
by
hoodaticus
(unregistered)
|
|
With that handle, do you play Bloodlines?
|
Yeah, but how many different values can a microsoft boolean have? I know its more than two. |
Re: The Matryoshka Method
2009-12-21 14:44
•
by
foxyshadis
(unregistered)
|
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. |
Re: The Matryoshka Method
2009-12-21 15:09
•
by
Some Wonk
(unregistered)
|
And Leon is getting larger... |
|
So, was anyone tempted to click the "Hear a Blog" link for more comic relief?
|
|
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? |
Re: The Matryoshka Method
2009-12-21 16:23
•
by
Katana
(unregistered)
|
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. |
Re: The Matryoshka Method
2009-12-21 16:35
•
by
iToad
(unregistered)
|
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. |
|
I think I spotted a typo; the "pmen" in the function name should be removed.
|
Re: The Matryoshka Method
2009-12-21 17:12
•
by
SomeCoder
(unregistered)
|
WIN. This comment is just full of WIN. |
Re: The Matryoshka Method
2009-12-21 18:05
•
by
hoodaticus
(unregistered)
|
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. |
Re: The Matryoshka Method
2009-12-21 18:07
•
by
hoodaticus
(unregistered)
|
ZOMG LOL! |
Re: The Matryoshka Method
2009-12-21 18:25
•
by
Quirkafleeg
(unregistered)
|
Only if you've poked one of its ‘I’s out. |
Hey, can I get an n-tier architecture on my resume with this?
"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!" |
|
One of the few articles that actually made me ask WTF out loud.
|
Re: The Matryoshka Method
2009-12-21 19:30
•
by
Hot Shot
(unregistered)
|
|
My eye!
|
| « Prev | Page 1 | Page 2 | Next » |