Are "Interfaces" anything more than a documentation mechanism
Hi, I'm reading through the Zope Developers Guide (http://www.zope.org/Documentation/Books/ZDG/current/index_html) and have a questions about the whole concept of interfaces and components. When I first saw this, I thought the Interface module was a way for accomplishing something similar to what you do with an abstract class in C++. In C++, you define an interface that has no implementation, so that any class that inherits from it must implement the interface defined in the abstract class. Thus any method that operates on the type defined by the interface doesn't care what the implementation is, and behold you have information hiding and polymorphism. My impression about the abstract class nature of the Interface module was aided and abetted by the following sentences on page 29 of the Developers Guide: "To turn a component into a product you must fulfil many contracts. For the most part these contracts are not yet defined in terms of interfaces. . . ." This statements makes it sound as is there is something architecturally significant about the relationship between a component and its interface. However, after having studied the Developers Guide more closely, and playing around with some examples at the interpreter prompt, it seems that the Interface module does nothing of the kind. There is no enforcement -- no mechanism for raising an error if a component that claims to implement an interface does not do so entirely. For example, if I add a method to the interface that is not implemented by the component, isImplementedByInstancesOf() still returns true. On the other hand, there is a rich set of Interface.base methods for viewing the documentation for an Interface and for querying an interface. So the Interface/Component mechanism is intended to be a method of documentation, along with a query mechanism that ties the documentation to the component class. It seems like it's a way of adding some discipline to the process of documenting the contract for a component. But if one were disciplined enough to document through some other mechanism -- like a plain old API doc -- the Interface thing would be superfluous. Have I understood this whole thing correctly, or am I missing something? By the way, I am aware that the question of whether and to what extent an abstraction mechanism (such as abstract classes in C++) would be useful in Python has already been discussed on comp.lang.python (see for example: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=82ads7q9u5.fsf%40 acropolis.localdomain&rnum=7&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DISO-8859- 1%26q%3Dpurpose%2Bof%2Binterface%2Bclass%2Bgroup%253Acomp.lang.python.*%26bt nG%3DGoogle%2BSearch). I certainly do not mean to cause a flame war about this question here. I'm just trying to understand what the Interface module is for. Many thanks! --Phil Philip Glaser Principal and Software Architect Sustainable Software Solutions, LLC StillSmallVoice@DirectvInternet.com www.sustainsoft.com 973-951-9522
Phil Glaser writes:
... "Interfaces" are rarely used in Zope2 (there are a few exceptions, e.g. the "pluggable indexes" of the ZCatalog).
But in Zope3, they will be fundamental for plugging components together... Dieter
Hi Dieter,
"Interfaces" are rarely used in Zope2 (there are a few exceptions, e.g. the "pluggable indexes" of the ZCatalog).
But in Zope3, they will be fundamental for plugging components together...
Ok, but that begs the question: are Interfaces architecturally significant, or is their utility retricted to providing a mechanism for documenting classes? I realized last night that my confusion about this was not only because of the superficial resemblance between interfaces/components and C++ abstract classes, but also because of COM: "interface," "Component," and the notion of querying an interface are core concepts in the COM architecture. But, again, unless I missed something, I did not see anything in the Interface documentation that would lead me to believe that Interfaces in Zope are anything more than a documentation mechanism. Thanks for your help! Regards, Phil
Phil Glaser writes:
But in Zope3, they will be fundamental for plugging components together...
Ok, but that begs the question: are Interfaces architecturally significant, or is their utility retricted to providing a mechanism for documenting classes? In Zope3, they will be architecturally significant.
Dieter
Hi Dieter,
Ok, but that begs the question: are Interfaces architecturally significant, or is their utility retricted to providing a mechanism for documenting classes? In Zope3, they will be architecturally significant.
Ah! So both statements are true: for _now_ they are only for documentation, AND in Zope 3 they will be architecturally significant. I _knew_ there must be something architectural going on here! Can you say more about _how_ they will be architecturally significant? Can you point me in the direction of some documentation on this, or give me a few hints? Many thanks!!! Phil
Phil Glaser wrote:
Can you say more about _how_ they will be architecturally significant? Can you point me in the direction of some documentation on this, or give me a few hints?
-> http://www.zope.org//Wikis/DevSite/Projects/ComponentArchitecture/ComponentA... regards Max M "klaatu verata niktu"
participants (3)
-
Dieter Maurer -
Max M -
Phil Glaser