Comment On Scaling Expandable Extensibility

It's days like this where I really think we need to be careful about exposing certain words and concepts we expose to "certain" programmers. What tends to happen, quite ironically, is that the "certain" programmer somehow manages to recreate the exact problem that a technology was designed to solve within the confines of that technology. [expand full text]
« PrevPage 1 | Page 2Next »

Re: Scaling Expandable Extensibility

2005-06-17 14:05 • by Yo
Holy crappola that is stupid

Re: Scaling Expandable Extensibility

2005-06-17 14:13 • by Carl
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?

Re: Scaling Expandable Extensibility

2005-06-17 14:13 • by GunslingerRR
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()"?

Re: Scaling Expandable Extensibility

2005-06-17 14:15 • by joynt
I guess arrays are out of the question.

Re: Scaling Expandable Extensibility

2005-06-17 14:17 • by John Smallberries
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.





Re: Scaling Expandable Extensibility

2005-06-17 14:18 • by loneprogrammer
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
36565 in reply to 36560
Anonymous:



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?



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
36566 in reply to 36563

John Smallberries:
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.



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.


[:|]

Re: Scaling Expandable Extensibility

2005-06-17 14:33 • by JamesCurran

So, bascially, the equivalent of


    MyFunc(1,2,"Hello");


would be


ExpandableFunction("MyFunc", "HelloWorld",null, null, 1, 2, null, null, null, null);


 


?

Re: Scaling Expandable Extensibility

2005-06-17 14:36 • by Matt B
What hapens when you call CInt on a String?

Re: Scaling Expandable Extensibility

2005-06-17 14:40 • by rogthefrog

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;


 

Re: Scaling Expandable Extensibility

2005-06-17 14:40 • by opus
36570 in reply to 36568
And no optional parameters?  Yick.

Re: Scaling Expandable Extensibility

2005-06-17 14:42 • by Jeff S
36571 in reply to 36567

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
36572 in reply to 36568
Matt B:
What hapens when you call CInt on a String?


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.

Re: Scaling Expandable Extensibility

2005-06-17 14:50 • by Voller

Alex Papadimoulis:
Public Function ExpandableFunction...
   'Yadda-yadda
End Sub


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
36577 in reply to 36573
Voller:

Alex Papadimoulis:
Public Function ExpandableFunction...
   'Yadda-yadda
End Sub


Spot the bonus-WTF...



I'm guessing that's just a bug in Alex's transciption/anonymizer code...

Re: Scaling Expandable Extensibility

2005-06-17 15:02 • by John Smallberries
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
36579 in reply to 36577
John Smallberries:
Voller:

Alex Papadimoulis:
Public Function ExpandableFunction...
   'Yadda-yadda
End Sub


Spot the bonus-WTF...



I'm guessing that's just a bug in Alex's transciption/anonymizer code...


I really need to get that fixed ;-)

Re: Scaling Expandable Extensibility

2005-06-17 15:15 • by strongarm
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.

Re: Scaling Expandable Extensibility

2005-06-17 15:19 • by Scott
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!!!

Re: Scaling Expandable Extensibility

2005-06-17 15:47 • by Carl
36582 in reply to 36565
John Smallberries:
Anonymous:



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?



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).





How would you pass 7 UDT's or COM objects?  Can't do it.  First 3 args are Strings.

Re: Scaling Expandable Extensibility

2005-06-17 15:55 • by Fregas

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
36584 in reply to 36582
Anonymous:
John Smallberries:
Anonymous:



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?



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).





How would you pass 7 UDT's or COM objects?  Can't do it.  First 3 args are Strings.


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
36585 in reply to 36584
Anonymous:

How would you pass 7 UDT's or COM objects?  Can't do it.  First 3 args are Strings.


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.

Re: Scaling Expandable Extensibility

2005-06-17 16:08 • by Carl
36586 in reply to 36584
John Smallberries:
Anonymous:
John Smallberries:
Anonymous:



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?



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).





How would you pass 7 UDT's or COM objects?  Can't do it.  First 3 args are Strings.


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.




Nope, it's 11...this function goes to 11...

Re: Scaling Expandable Extensibility

2005-06-17 16:13 • by Rank Amateur

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, _

ByRef sArg1 As String, ByRef sArg2 As String, ByRef sArg3 As String, _
ByRef vArg1 As Variant, ByRef vArg2 As Variant, ByRef vArg3 As Variant, _
ByRef oArg1 As Object, ByRef oArg2 As Object, ByRef oArg3 As Object)
Select Case strFunctionName
Case "CREATE"
    ExpandableFunction = Create(sArg1, sArg2)

...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
36588 in reply to 36586

Anonymous:
John Smallberries:
Anonymous:
John Smallberries:
Anonymous:

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?

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).


How would you pass 7 UDT's or COM objects?  Can't do it.  First 3 args are Strings.

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.


Nope, it's 11...this function goes to 11...


Talk about mudflaps, this code's got 'em....

Re: Scaling Expandable Extensibility

2005-06-17 17:13 • by loneprogrammer
36590 in reply to 36585
John Smallberries:
You could pass 9 COM objects.
The first 3 strings would have to be ProgId's, which you would CreateObject() on.


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.



Re: Scaling Expandable Extensibility

2005-06-17 17:15 • by Hank Miller
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
36593 in reply to 36591
Anonymous:
somethign like:



call = "initialize"

start:

    Switch Case call

        Case "initialize"

            ...

           call = "nextWhatever"

           goto start   



This seems familiar somehow.



Re: Scaling Expandable Extensibility

2005-06-17 18:18 • by tag
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 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.










































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!

Re: Scaling Expandable Extensibility

2005-06-17 18:19 • by tag
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.

Re: Scaling Expandable Extensibility

2005-06-17 18:20 • by tag
36596 in reply to 36583
Anonymous:

Well, its in VB, which is loosely typed anyway.  So i don't really see what difference it makes.  [;)]


hahahahahahahaha!!!!!!!!!!!!  What a knob gobbler...





You mean dynamically typed.

Re: Scaling Expandable Extensibility

2005-06-17 20:21 • by Otac0n
36597 in reply to 36596

You guys are morons, this is a part of a scripting engine.


It takes a function with tokenized parameters.


Lamers, bashing without a clue.

Re: Scaling Expandable Extensibility

2005-06-17 21:12 • by Hawk777
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!!!



;)

Re: Scaling Expandable Extensibility

2005-06-17 22:01 • by davidmwilliams

What about the fact every parameter is passed by REFERENCE !!!!!!!!

Re: Scaling Expandable Extensibility

2005-06-17 22:22 • by Tim Hall
36600 in reply to 36597
"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
36602 in reply to 36597


>You guys are morons, this is a part of a scripting engine.

>It takes a function with tokenized parameters.

>Lamers, bashing without a clue.


Maybe us morons and lamers have heard of Eval before ?


T.


Re: Scaling Expandable Extensibility

2005-06-18 20:12 • by Otac0n
36608 in reply to 36602
Anonymous:

>You guys are morons, this is a part of a scripting engine.
>It takes a function with tokenized parameters.
>Lamers, bashing without a clue.


Maybe us morons and lamers have heard of Eval before ?


T.



 


sure, but that could potentially lead to serious security holes.

Re: Scaling Expandable Extensibility

2005-06-19 11:33 • by ammoQ
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
36625 in reply to 36619
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!

Re: Scaling Expandable Extensibility

2005-06-20 02:51 • by Sten
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
36628 in reply to 36591

Anonymous:
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?


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.

Re: Scaling Expandable Extensibility

2005-06-20 03:45 • by anon
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
36630 in reply to 36629
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.

Re: Scaling Expandable Extensibility

2005-06-20 06:34 • by AntiDragon
How un-fecking-believable...Really...

....Must go sit in my quiet place now....

Re: Scaling Expandable Extensibility

2005-06-20 08:04 • by IceFreak2000
36632 in reply to 36628
Anonymous:

Anonymous:
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?


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.





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
36633 in reply to 36572
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.


Incorrect. If the string is not numeric, CInt returns a 0.

Re: Scaling Expandable Extensibility

2005-06-20 09:52 • by Not Alone

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...

« PrevPage 1 | Page 2Next »

Add Comment