[Zope3-dev] "common" or "basic" interface types?

Mike C. Fletcher mcfletch@rogers.com
Thu, 13 Mar 2003 23:37:51 -0500


Tim Peters wrote:

>[Mike C. Fletcher]
>  
>
>>...
>>I've got enough at the moment to cover the base operations of:
>>    string, unicode, list, tuple, and dictionary
>>still lots more to go.
>>    
>>
>
>Mike, take a peek at interfaces.py in src/zodb/btree.  In fact the
>interfaces there appear to be implemented only by ZODB's BTree-based data
>structures, but it looks like substantial effort went into trying to make
>them applicable to sequences and mappings in general.  Then again, there's
>sometimes *some* oddball method mandated that cuts off the possibility of
>realistic reuse (like IDictionaryIsh specifies a byValue method that
>probably won't be implemented by anything other than a BTree with integer
>values used specifically for mapping documents to integer search-relevance
>scores).  "Keep it simple" probably helps <wink>.
>  
>
I'm definitely trying to "keep it simple" (but when have you ever seen 
me succeed at that goal ;) ).  For the core interfaces, I'm defining 
basically one interface per de facto interface (which is normally a 
single attribute or method for the core types, with a few minor 
exceptions, such as IStreamClose, where two elements are codependent). 
 Most of these methods/attributes exist without necessary reference to 
one another.  Defining each as an interface (which, in my opinion, they 
are) should allow for targeted adapter assemblies, rather than generic 
ones that have more "slosh" due to their broader functionality.

For instance, I can imagine an adapter for IObjectIter (or possibly a 
sub-interface that explicitly declares "restart ability") which allows 
objects to forego defining IObjectContains (doing a for loop over the 
iterator for the object).  If the interfaces are "heavy" 
(IListLikeObject), that adaptation becomes more problematic.

What I'm assuming will happen is creating higher-level interfaces such 
as seen in the btree interfaces via either composition (the interface 
appears directly in class.__implements__) or by creating child 
interfaces with specialized functionality.  BTW, you're right, there's 
very few standard interfaces in the BTree interfaces module, even if the 
method-names are the same as common interfaces, and there is obviously 
some work at "generality" in naming.

Enjoy,
Mike

_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/