Python (well...Zope) Interfaces
by Jeremy Jones
Some time back, I had read about Zope interfaces. I didn't really think much about them at the time, but now I'm giving thought to using them. Since the Python language does not provide linguistic constructs to specify an interface (at least, not like some languages do), I thought it might be helpful (if for no other reason than documentation and design) to use something like Zope interfaces to help build my workflow manager.
The alternative is to proceed as I had begun and lay out some empty "base" classes which will contain the methods which I expect "concrete" classes to contain. And rely on unit tests to enforce that instances of each concrete class will have the appropriate methods behaving in the appropriate way. (And I would assert that using unit tests is the right way to go even if you use "proper" interfaces.)
Now that I've layed out my situation, I have a question. Is there really any value to something like Zope interfaces? And if there really is benefit, is it merely documentational and design-oriented which could be achieved with convention without having to rely on a tool such as Zope interfaces? Please post your comments here, as I'm really interested in reading what others thing on the subject.
While Zope interfaces are useful for documentation and so on, if that were there only benefir I wouldn't consider them a good investment. Instead, you should consider the advantages you get in compositional flexibility by using them with adaptation.
Some insight here?