- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
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)
Admin
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.
Admin
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.
Admin
The code looks very enterprisey.
Admin
Unchecked, as opposed to all of them declared Variant?
Admin
Stack overflow at line 0.
Admin
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
Admin
-Harrow.
Admin
Admin
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.
Admin
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.
Admin
Ha! +1 on this one. I'm bored.
Admin
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 ?
Admin
It burns my eyes AND o my god, the humanity
Admin
Admin
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?
Admin
That's no moon!
Admin
/me wonders where the inputs are(n't?) sanitized at?
Admin
Shipping-related fields... table with almost one-to-one equivalency... and somehow, somewhere, XML is inserted?
Admin
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.
Admin
Awww cute, someone's sticking up for his pal.
Admin
The real Matryoshka Method is to stick everything inside an .MKV file.
Admin
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.
Admin
Does your brain work properly? Do you think calling something an "anti-pattern" is an endorsement?
Bad code is bad.
Admin
And Long Cat is Long!!
(sorry, couldn't resist....)
Admin
My mistake. Given that assumption, it seems entirely reasonable to assume that you meant to endorse an "anti-pattern."
Admin
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.
Admin
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.
Admin
Admin
VB6 has classes bra. The huge number of arguments is a giant cluebat that the coder was clueless.
Admin
Gee...and then we wonder why we need EHz processors to see a cat jump in a box and fall over.
Admin
LOL- with all those arguments, this "function" returns what for error information? A Boolean.
Admin
Maybe the developers wanted to get "n-tier architecture" on their resumes.
Admin
With that handle, do you play Bloodlines?
Admin
Yeah, but how many different values can a microsoft boolean have? I know its more than two.
Admin
Admin
Clearly the sane thing to do is to change the return value from Boolean to Variant.
Admin
And Leon is getting larger...
Admin
So, was anyone tempted to click the "Hear a Blog" link for more comic relief?
Admin
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?
Admin
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.
Admin
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.
Admin
I think I spotted a typo; the "pmen" in the function name should be removed.
Admin
WIN. This comment is just full of WIN.
Admin
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.
Admin
ZOMG LOL!
Admin
Admin
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!"
Admin
One of the few articles that actually made me ask WTF out loud.
Admin
My eye!