[Zope3-dev] Re: Basic Interfaces question
Tres Seaver
tseaver at zope.com
Mon Jun 7 11:42:35 EDT 2004
Jim Washington wrote:
> Philipp von Weitershausen wrote:
>
>> Jim,
>>
>> > Let's say we have an interface IFoo and an interface IFooExtended
>> >
>> > IFoo defines foo as
>> >
>> > def foo():
>> > """do foo"""
>> >
>> > IFooExtended defines foo as
>> >
>> > def foo(myParam=None)
>> > """do the same thing as foo in IFoo, except use myParam to extend
>> > behavior if available"""
>> >
>> > should IFooExtended descend from IFoo, or should IFooExtended be a
>> > different interface?
>> >
>> > i.e., should the definition of IFooExtended be
>> >
>> > class IFooExtended(IFoo):
>>
>> Usually you would subclass the IFoo interface, but it really depends on
>> the meaning you attach to IFooExtended. Are things that are IFooExtended
>> also IFoo? Judging by the name IFooExtended, I would think so, but it
>> depends on the meaning you want to give it.
>>
> Yes, IFooExtendeds would also be IFoos; the question is whether the
> optional parameter makes foo() a sufficiently different interface to
> necessitate a complete interface definition. I presume that
> implementation classes could implement both. Are there technical reasons
> that a minor interface extension like this would make redefinition
> desirable?
From a practical perspective, the extra argument won't be usable by
other components unless they can safely test for your extension;
defining the new interface makes that test safe and sane.
In addition, it might let you register different components for the
extension, should that matter.
Tres.
--
===============================================================
Tres Seaver tseaver at zope.com
Zope Corporation "Zope Dealers" http://www.zope.com
More information about the Zope3-dev
mailing list