[Interface-dev] twisted developer writing zope component system tutorial

Jim Fulton jim at zope.com
Thu May 27 12:43:35 EDT 2004


Jonathan Simms wrote:

> Hi everyone, I'm a twisted developer and I'm writing a tutorial on
> both how and why one uses a component system, and more specifically
> how twisted's integration with zope.interface works and the best
> practices for using it.

Great!

> I've been trying to think of a good example for explaining a
> general-case situation where zope.interface.classProvides is useful.
> The example of having an IFooFactory doesn't seem like it would come
> up all that often. Then again, perhaps that's either just my
> inexperience or something inherent in the nature of using
> classProvides.

That's right.  It is not often necessary to declare interfaces
for classes, because we don't tend to use classes for much more
than instance factories in Python.  Still, it is still sometimes
useful. Consider, for example, representing the static methods in
datetime.

I find classImplements most useful when explaining why __init__
if not part of an instance's interface. :)

The broader concept if the distinction between "implements"
and "provides".  When we use "implements", we are talking about
the interfaces of the objects produced by an object. When we
say "provides" we are talking about the interfaces of the object
itself.  We often declare interfaces for individual instances.

 > Why would describing the interface that an "instance
> factory" be useful in terms of adaptation? or is that not the point?

It's not so much that you want to talk about the interfaces of
a factory, it's that you want to be able to talk about the interfaces
of any object, independent of whether they happen to be factories.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org




More information about the Interface-dev mailing list