[Zope3-dev] Context and Component Lookup
Phillip J. Eby
pje at telecommunity.com
Thu Aug 7 12:23:46 EDT 2003
At 05:11 PM 8/7/03 +0200, Martijn Faassen wrote:
>Jim Fulton wrote:
>[snip]
> > Oh come on. Encapsulation is provided through interfaces. If a component
> > claims to depend on an interface, but isn't willing to accept alternate
> > components that implement the interface, then *there* is the encapsulation
> > problem. When we use the component architecture, it's because we *want*
> > to be used with alternative components. All we depend on is the interface.
>
>But if using an alternate component means I need to *know* which components
>are going to be looked up by that alternate component so I can actually
>supply them in my context, then *that* breaks encapsulation. I shouldn't
>have to know which components are looked up by another component in
>order to use it. It's specified nowhere in the interface. Are you saying
>this should be specified in the interface?
Actually, this is a good point, one that I didn't think to make
explicit. That is, one must document the requirements of a component, and
these requirements are distinct from the requirements of the interface that
the component is a supplier of. This is like having 3-volt and 5-volt
versions of the same chip. They may supply the same interface, but have
different requirements for their context.
There is no formal way to document this in either Zope or PEAK at present;
it's just "documentation". In PEAK, though, components have explicit
"out-bindings" like the pins of a chip, so you can usually browse these in
the source without reading method bodies to see what lookups are
occurring. (Which is probably why I didn't think about it explicitly in
this discussion.) Perhaps a similar approach would be useful in Zope, or
perhaps some type of "component requirements schema" object, if that's more
fitting of Zope's overall style.
More information about the Zope3-dev
mailing list