[Zope3-dev] adaptation based on class rather than interface
Martijn Faassen
faassen at infrae.com
Thu Nov 9 10:18:32 EST 2006
Martin Aspeli wrote:
>
> Chris Withers wrote:
>> I find myself often having to define pure marker interfaces for each
>> class that I define, purely so I can register adapters for objects of
>> that class.
>
> Why does your class not have a (non-marker) interface in the first place?
> The use of interfaces as documentation and as formalisms for expressing a
> class' functionality (in adapters, utilities etc) is one of the benefits
> that Zope 3 introduces. I can see how they may not always add that much
> value immediately, but they are a good way of ensuring things are reasonably
> well-defined, well-documented and easily locatable. I'd rather start from
> interface design and implement as necessary, than think of interfaces as
> necessary evils of the CA, personally.
Oh, I disagree. It's much nicer to be able to be able to start with
adapting classes, and introduce interfaces later, where necessary. Often
they're not. In fact it's already possible to adapt classes and register
views for classes. In ZCML I believe there's some limitations with one
directive or other (a bug), at least there was, but the component
architecture has allowed this for a long time. We've been very happily
using this in grok.
C++ also encourages/enforced the writing of a .h file describing the
interface for all classes. I then learned Python and was much happier.
Zope 3 should allow for the Pythonic pattern of development.
Regards,
Martijn
More information about the Zope3-dev
mailing list