[Zope3-dev] adaptation based on class rather than interface

Jean-Marc Orliaguet jmo at ita.chalmers.se
Thu Nov 9 10:01:21 EST 2006


Lennart Regebro wrote:
> On 11/9/06, Chris Withers <chris at simplistix.co.uk> wrote:
>> Why do you say "extra" ZCML registration? You need that ZCML
>> registration whether or not you have to write the marker interface...
>
> Sure, but with the marker interface you need only one. You need one
> for each class, in your example, thats two. So the second one is
> "extra". :)
>

I think it is a mistake to use interfaces to specify what object _are_ 
as opposed to what they can _do_. It is better to use base classes for 
that. I agree with Chris that making classes adaptable would be simpler.

Interfaces were designed to specify what an object can do, e.g. a media 
player will do: play(), stop(), rewind(), without specifying the actual 
implementation ... whereas classes tell what objects are (an mp3 player, 
an LP player, a cassette player, ...), they are more specific to the object.

And there is nothing wrong with using inheritance when there is a '__IS 
A __' type of relation (e.g. an ordered folder IS A folder IS AN item, 
...), or if there is a HAS_A type of relation (a folder has items, a 
chair has four legs...). It seems that Zope3 has banned all form of 
class inheritance, even those that made sense, and that would have 
simplified the implementation.

"marker interfaces" have empty specifications, that's the problem: they 
can't grow into "real" interfaces that have a specification. If you add 
methods to the marker interface you will have to track down all classes 
that implement the interface (unless you don't really care whether 
classes do implement their interface).

/JM


More information about the Zope3-dev mailing list