[Tutor] Re: Re: Factory classes (etc)

Arthur ajs@ix.netcom.com
Fri, 6 Sep 2002 21:21:52 -0400


Magnus -

> > But in most cases where you use overloading or templates in
> > C++ etc, you just write one method in Python, and that's it! :)
> > Perhaps you need an extra if-statement in the method, but I
> > have never missed method overloading in Python during the six
> > years I used it.

Alan -
> I agree

Being that this is the 5th or 6th time I've heard exactly the same take from
folks with deeper programming experience than myself, I kind of feel the
need for a reality check.

I am not "missing" method overloading in the sense that I feel Python is
somehow deficient by not having it built-in.  Because in fact I don't see
anything
very deep about method overloading at all.  It's just about what things are
called, not what they do.  There is the simple option of giving 2 classes
that take different arguments different names, and having an API defined
accordingly.  As well as  numbers of other options.

The irony of all this being that if I was working in Java, or C++ I would
be much happier with that kind of solution, because a true API for a
Java or C++ library is a neccessity, or at least expected, in any case,
and if there were not method overloading it would be easy enough
to compensate by an appropriately documented API.

But for what I am doing I want to build as much as I can a scripting
interface that follows geometric intuitive logic, not programmers logic.
And at the scripting interface level what things are called *is* to the
essence
of things. If a point is instantiated as an Intersection, if might be the
intersection of a number of other possible elements. It is absolutely
redundant
both to have the Intersection classes named in accordance with what elements
they take as arguments, and then to give them those arguments - because in
fact the arguments themselves define the kind of intersection we are
trying to create.

Given lets say 20 classes which could take anywhere from one to
five different sets of arguments, and thats a hell of a lot of
if type(arg[0]):
   xxx
else:
   yyyy

to try to get right and keep straight.

And forcng the scripter to name all arguments is not an acceptable
solution, from my point of view.

So, I actually feel I am on quite the right track by trying to come up with
an algorythmic solution - which I am comfortable is doable. Probably
cake for someone with more algorythmic experience and intuition than I have.

And, yes, the concepts of running it all through Factory Classes is not
something
I understood to consider.  Brought tio my attention, it seems the obviously
best
way to go - but I still need my algorythms.

So I am both supremely confident, and horribly insecure - about being on a
sensible track.

Art