[Zope3-dev] IFactory, and composite factories

Brian Lloyd brian@zope.com
Tue, 3 Sep 2002 09:49:07 -0400


> >>"Factory" is a pretty general term that we are using for two different
> >>things.
> >>
> >
> > Yeah.  It's appropriate in both contexts, but I'd almost rather
> > rename the content Factory somehow to create a separation.
>
> Maybe. I'm not sure. I misspoke earlier. IFactory is really meant
> for simple factory components. The objects created could be components or
> other objects.  Brian Lloyd lobbied for this based on experience with COM.
> I've CCed him to try to drag him into this conversation. ;)

<drag... drag... kick... scream... > :)

One of my main goals for arguing for that earlier was to duplicate
the (relative) simplicity in that environment in that there is "one
true lowest-common-denominator way" to get an instance of (any) object
created. There are other ways to get an object created, but those ways
are closer to the application or framework layer and all build on or
mediate for the basic "IClassFactory" interface (misnamed, as it
creates instances, not classes).

While I still think there is value in having a simple core mechanism
like this, I think things have evolved to a point where the way you
create something depends a lot on what you want to create and how you
intent to use it. I also think our usage pattern has evolved into
something fairly different than the "generic" component models (COM,
CORBA, et. al.) support, so I feel less driven to "do things in a
way that will feel familiar to people".

>
> The main purpose of IFactory is to support "createObject", so I suppose
> that another term would be "creator".
>
> Another option is to rename the factory attribute in ZCML.

I agree that we should avoid overloaded terms, though I don't have a
good suggestion for a better name. FWIW, .NET now calls this thing
"Activator", and its job is still to create instances of things at
runtime without requiring early binding. In Python / Z3 terms, it
would support the "create me an XML parser" use case from Python
code without the Python code having to import (early-bind) the
dependency.

I don't know if it helps the situation, but we could rename the
IFactory to something like IComponentFactory which (to me, anyway)
has the ring of a lower-level basic facility. (or IComponentCreator,
etc,)



Brian Lloyd        brian@zope.com
V.P. Engineering   540.361.1716
Zope Corporation   http://www.zope.com