| « Prev | Page 1 | Page 2 | Next » |
|
Holy crappola that is stupid
|
|
Stuff like this makes my head hurt.
The other WTF, assuming this is a good idea, is that it can only accept 3 arguments for any function. Not very expandable, now is it? |
|
Wait, so this function takes a ton of arguments...only to perform several different functions in a switch/case?
What is so hard about making a simple function "create()"? |
|
I guess arrays are out of the question.
|
|
omg.
I've seen this before. I worked with a guy who was asked to write a database access layer. He came back a month later with a single function that accepted a string parameter, did a massive switch/case, and executed whatever dynamic sql block the param was supposed to specify. |
|
Truely this person must be a master of the Dark Side of the Force,
to take something good and pure and twist it into something so wrong. |
Re: Scaling Expandable Extensibility
2005-06-17 14:20
•
by
John Smallberries
|
No, it accepts up to 9 args. I also like that he specified Variants and Objects. I thought Variants could also hold object references. (my VB is rusty, so I could be wrong on this). |
Re: Scaling Expandable Extensibility
2005-06-17 14:28
•
by
rogthefrog
|
Poor Giles Olaliberries. You've certainly seen horrible things. I think today's WTF is a GREAT example of overloading. I'm sure the whole JVM is implemented that way behind the scenes. [:|] |
|
So, bascially, the equivalent of MyFunc(1,2,"Hello"); would be ExpandableFunction("MyFunc", "HelloWorld",null, null, 1, 2, null, null, null, null);
? |
|
What hapens when you call CInt on a String?
|
|
Matt should tell that predecessor of his about operator overloading. I shudder to think what that person would come up with for String a = "stuff "; String b = "your face"; String ab = a + b;
|
|
And no optional parameters? Yick.
|
Re: Scaling Expandable Extensibility
2005-06-17 14:42
•
by
Jeff S
|
|
he he .. this is too much. OK ... Maybe he got tired of declaring variables and all those silly compile-time errors, so he turned off Option Explicit. But even after doing that, the damn compiler STILL complained ! He then realized that apparently it still wanted him to declare all the functions and procedures as well ! How annoying! The ingenius solution (that I am sure he is quite proud of) : Make all function and procedure names TEXT STRINGS, all called through this one function, so that you NEVER get a compile time error ! And no annoying declaration statements in your code is needed ! Only 1 function name to spell correctly and remember ! In fact, with this new model, no more errors will *ever* occurr at design time OR run-time ! This might be the best code this planet has ever seen, or ever will! Truly, a masterpiece ! |
Re: Scaling Expandable Extensibility
2005-06-17 14:49
•
by
John Smallberries
|
If the string is numeric, the converted (& truncated if decimal) int is returned. If it's not, an exception is thrown (whoops...VB...) it blows up. |
Spot the bonus-WTF... |
Re: Scaling Expandable Extensibility
2005-06-17 14:51
•
by
The asterisk is on the side I'm not looking at
|
|
While the first line of the description is a little over "exposed", it does set up the horror beneath fairly well.
|
Re: Scaling Expandable Extensibility
2005-06-17 14:54
•
by
John Smallberries
|
I'm guessing that's just a bug in Alex's transciption/anonymizer code... |
|
Also, there's no return type for the function, so it defaults to Variant.
The caller has to know that "CREATE" (or whatever function) is supposed to return an Object (or whatever type) so it can cast it. Makes it even harder to use. Maybe this is a misguided attempt to code anonymous methods or Lisp-style lambda functions in VB. Or maybe it's just a big, fat, steaming WTF. ugh. Why do I keep looking at it? |
Re: Scaling Expandable Extensibility
2005-06-17 15:06
•
by
Alex Papadimoulis
|
I really need to get that fixed ;-) |
|
there are legitimate times when control coupling makes sense (pick any number of GoF patterns - Factory, Command, Strategy, Decorator)...this is not one of them and this is certainly not a good way to implement it.
I now not only have to write new code to consume the function, but at a new select statement and the new function itself. I think tomorrow we should teach this programmer about polymorphism. It'll be a duct tape moment for sure (wrap duct tape around their head so when it explodes, it keeps the pieces from flying everywhere -- we used to do the same thing for our computers during hurricaines using duct tape and garbage bags). If you're going to reinvent the wheel, try not to make it a triangle or a rectangle. |
|
This is brilliant! I've always wondered whether or not it would
be possible to write a program that is completely recursive. I'd never thought of doing anything this crazy though! Awesome!!! |
How would you pass 7 UDT's or COM objects? Can't do it. First 3 args are Strings. |
|
Well, its in VB, which is loosely typed anyway. So i don't really see what difference it makes. [;)] hahahahahahahaha!!!!!!!!!!!! What a knob gobbler... |
Re: Scaling Expandable Extensibility
2005-06-17 16:00
•
by
John Smallberries
|
I didn't say what types those 9 could be. If you wanted to pass 6 strings and 3 objects, no problem. Last I checked, 6+3 = 9. |
Re: Scaling Expandable Extensibility
2005-06-17 16:05
•
by
John Smallberries
|
You could pass 9 COM objects. The first 3 strings would have to be ProgId's, which you would CreateObject() on. The other 6 could be references to object instances. |
Nope, it's 11...this function goes to 11... |
|
After a sound beating with the clue bat, Matt’s predecessor becomes enlightened on the True Meaning of functions! In a 48-hour coding marathon, he rewrites the entire code to a new and much improved form! Oh, it still has Function ExpandableFunction(), but now it’s written as: Public Function ExpandableFunction(ByVal strFunctionName As String, _ ...and so on. Matt reaches for the bigger clue bat. --RA "Do. Or do not. There is no try. Except in C#." –Yoda |
Re: Scaling Expandable Extensibility
2005-06-17 16:36
•
by
MikeB
|
Talk about mudflaps, this code's got 'em.... |
Re: Scaling Expandable Extensibility
2005-06-17 17:13
•
by
loneprogrammer
|
You could pass unlimited parameters by converting them into XML and stuffing them into the first String parameter. And that would work across the network... I think I'll call that... BORAX. No... SOAP. |
|
Granted I haven't done Basic since my Atari days. (Must not
make smart comment about how much better it was than the C64) but can't he eliminate that one function with a goto somehow? somethign like: call = "initialize" start: Switch Case call Case "initialize" ... call = "nextWhatever" goto start Again, I have not used VB at all, but isn't there a syntax something like the above that would eliminate the need for even one function. Afterall if you are going to write bad code, why not go all the way? |
Re: Scaling Expandable Extensibility
2005-06-17 17:34
•
by
loneprogrammer
|
This seems familiar somehow. |
|
You know, the stuff I have to deal with here makes most of these posts look like nothin'.
Here is one of the BEST segments of code I have seen in this system: var test= mainStr.split("|"); for(var i=0; i<=4;i++) { switch (i) { case 0: { sHTML += 'Affiliation' + '="' + test[i] + '" '; break; } case 1: { sHTML += 'Product' + '="' + test[i] + '" '; break; } case 2: { sHTML += 'Company' + '="'+ test[i]+ '" '; break; } case 3: { sHTML += 'CompanyGroup' + '="'+ test[i]+ '" '; break; } case 4: { sHTML += 'Persona' + '="' + test[i] + '" '; break; } break; } } Obviously, this is a total wtf...why in the... But that's nothing! Nothing I tell you. I run into stuff like this *daily* Keep in mind the stuff in the CDATA sections is supposed to be perl, that the optional index. Key word in that statement is optional. The dcr sections come from this really nasty mechanism called a "data capture record", and they are basically equivilent to records of input. And if thats not bad enough for you, at the end of the template is this... my $pt_name = iwpt_get_pt_name(); $pt_name =~ s{.tpl}{_p.tpl}g; my @args = ('C:/Interwoven/iw-home/local/bin/generate_pfile.ipl', "$workarea", "$dcr_name", "$pfile_name", "$pt_name"); `@args`; } ]]> And I've got thousands and thousands of lines of this crap to wade through. That's right, You remember correctly. == is a numerical comparison and there are no "true" or "false" boolean primitives in perl. All I have to say is, thank goodness this is a contract! |
|
You know, the stuff I have to deal with here makes most of these posts look like nothin'.
Here is one of the BEST segments of code I have seen in this system: var test= mainStr.split("|"); for(var i=0; i<=4;i++) { switch (i) { case 0: { sHTML += 'Affiliation' + '="' + test[i] + '" '; break; } case 1: { sHTML += 'Product' + '="' + test[i] + '" '; break; } case 2: { sHTML += 'Company' + '="'+ test[i]+ '" '; break; } case 3: { sHTML += 'CompanyGroup' + '="'+ test[i]+ '" '; break; } case 4: { sHTML += 'Persona' + '="' + test[i] + '" '; break; } break; } } Obviously, this is a total wtf...why in the... But that's nothing! Nothing I tell you. I run into stuff like this *daily* Keep in mind the stuff in the CDATA sections is supposed to be perl, that the <iw_ tags get compiled into perl at runtime and eval'd (A really really ugly system that comes from the vendor, but wait until you see them actually use it). <iw_iterate> is a for-each loop and "iter" is an optional index. Key word in that statement is optional. The dcr sections come from this really nasty mechanism called a "data capture record", and they are basically equivilent to records of input. <iw_iterate var="scroll" list="dcr.ScrollingDisclaimer" iter="count71"> <iw_perl><![CDATA[ if ($disclaimerflag < 0 || $disclaimerflag == 0) { $disclaimerflag = 1; } if (!defined $disclaimerflag || $disclaimerflag == "") { $disclaimerflag = 1; } ]]></iw_perl> </iw_iterate> <iw_iterate var="nonscroll" list="dcr.NonScrollingDisclaimer" iter="count72"> <iw_perl><![CDATA[ if ($disclaimerflag < 0 || $disclaimerflag == 0) { $disclaimerflag = 1; } if (!defined $disclaimerflag || $disclaimerflag == "") { $disclaimerflag = 1; } ]]></iw_perl> </iw_iterate> <iw_iterate var="scrolldisclaimer" list="dcr.ScrollingDisclaimer" iter="count79"> <iw_perl><![CDATA[ $disclaimer = iwpt_dcr_value("scrolldisclaimer.DisclaimerText"); if ($disclaimerflag gt "0" || $disclaimerflag != 0) { iwpt_output(" <div class=\"scrolldisclaimer\">$disclaimer</div> "); } ]]> </iw_perl> </iw_iterate> <iw_iterate var="nonscrolldisclaimer" list="dcr.NonScrollingDisclaimer" iter="count79"> <iw_perl><![CDATA[ $nondisclaimer = iwpt_dcr_value("nonscrolldisclaimer.DisclaimerText"); if ($disclaimerflag gt "0" || $disclaimerflag != 0) { iwpt_output(" <div class=\"nonscrolldisclaimer\">$nondisclaimer</div> "); } ]]> </iw_perl> </iw_iterate> And if thats not bad enough for you, at the end of the template is this... <iw_perl><![CDATA[ if (iwpt_dcr_value("dcr.Option.PrinterFriendly") == true && iwpt_dcr_value("dcr.Option.PrinterFriendly") != false) { $dcr_name = iwpt_get_dcr_name(); $workarea = iwpt_get_dcr_name(); $iw_home = TeamSite::Config::iwgethome(); $workarea =~ s#\\#/#g; $workarea =~ s#(/WORKAREA/[^/]+)/.*#$1#; # Strip off anything after "/WORKAREA/$WAName" my $pt_name = iwpt_get_pt_name(); $pt_name =~ s{.tpl}{_p.tpl}g; my @args = ('C:/Interwoven/iw-home/local/bin/generate_pfile.ipl', "$workarea", "$dcr_name", "$pfile_name", "$pt_name"); `@args`; } ]]></iw_perl> That's right, You remember correctly. == is a numerical comparison and there are no "true" or "false" boolean primitives in perl. |
You mean dynamically typed. |
Re: Scaling Expandable Extensibility
2005-06-17 20:21
•
by
Otac0n
|
|
You guys are morons, this is a part of a scripting engine. It takes a function with tokenized parameters. Lamers, bashing without a clue. |
|
Uhh... guys... I've got a brilliant idea for how to re-implement this!
OK, here goes: 1. Put all the functions you could possibly want to call into a separate source file. All functions accept nine parameters. Compile it with debugging turned on (MUST be turned on!) 2. Write a script that pulls the symbol table from the debugging info and writes an XML file with the name of each function and its address. 3. When you want to call a function, you call a dispatcher function which... 4. invokes a JavaScript engine which... 5. runs a JS file which parses the XML file and... 6. returns the address of the function, which is then... 7. called by the original dispatcher function, with the 9 parameters. There you go! No need for complicated dependencies! It actually makes your program compile faster, because changing the set of exported functions doesn't break existing binary objects so they don't have to be recompiled... because you just add a new call to the dispatch... wait... they wouldn't be recompiled anyway because they're already exported... I mean... wait... screw it I can't defend it, but... IT USES JAVASCRIPT AND XML SO IT MUST BE GOOD!!! ;) |
|
What about the fact every parameter is passed by REFERENCE !!!!!!!! |
Re: Scaling Expandable Extensibility
2005-06-17 22:22
•
by
Tim Hall
|
|
"this is a part of a scripting engine."
That was the first thing i thought of, infact i started ti write something like that (i knew it was bad but i couldnt find any other way), then i came across the brilliant CallByName function which made it a lot nicer. |
Re: Scaling Expandable Extensibility
2005-06-18 09:34
•
by
Konijn
|
|
>You guys are morons, this is a part of a scripting engine. Maybe us morons and lamers have heard of Eval before ? T. |
Re: Scaling Expandable Extensibility
2005-06-18 20:12
•
by
Otac0n
|
sure, but that could potentially lead to serious security holes. |
|
I always wondered how you can do aspect oriented programming in VB... now I know the answer ;-)
|
Re: Scaling Expandable Extensibility
2005-06-19 21:00
•
by
Jon Limjap
|
|
This is great! It's like that time when the Adam West Batman poured
alphabet soup unto the Bat Computer to solve The Riddler's riddle! |
|
The linux kernel code for socketcall() looks remarkably like
this. Just why they didn't implement one system call per socket function is beyond me. Fun, Sten |
Re: Scaling Expandable Extensibility
2005-06-20 03:20
•
by
Mario
|
But you did anyway, didn't you? There is nothing better than a C64. Up to today, the Information Technology industry is struggling to make a system as innovating as our beloved Commodore 64. |
|
Been there, called that; with XML documents passed as strings for bonus points.
It was a CORBA server (also in a COM edition); the excuse for inflicting users a single method interface was reducing coupling and binary dependencies. |
Re: Scaling Expandable Extensibility
2005-06-20 05:26
•
by
Bellinghman
|
|
Just look at IDispatch::Invoke in COM. Any function you like called through that.
But that is an early-bound function enabling a late-bound interface, so it's got good reasons for its existence. |
|
How un-fecking-believable...Really...
....Must go sit in my quiet place now.... |
Re: Scaling Expandable Extensibility
2005-06-20 08:04
•
by
IceFreak2000
|
I think you made a slight spelling mistake s/Commodore 64/BBC Micro/ s/C64/Beeb/ There - all better now! |
Re: Scaling Expandable Extensibility
2005-06-20 08:55
•
by
boohiss
|
Incorrect. If the string is not numeric, CInt returns a 0. |
|
At least it's only ONE function. The SQL DB I inherited uses the same "logic" in all the stored procedures, only using a passed in "function" parameter instead of the strFunctionName and a series of IF statements in the SP. The same set of additional parameters is used in every stored procedure. Each proc can return various result sets and/or perform various updates to the database. And every proc is called exactly the same as every other except for the name of the proc. Maintenance is a NIGHTMARE!
But at least I'm not the only one to have to deal with this madness - as today's WTF shows... |
| « Prev | Page 1 | Page 2 | Next » |