[Zope3-Users] To Subclass, or to Adapt?

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Aug 10 14:36:07 EDT 2005

On Wednesday 10 August 2005 14:01, James Allwyn wrote:
> I would appreciate any guidance on what the
> recommended Zope3-ish way of handling this would be. I
> feel the options are either to create a generic
> IProperty object, and subclass it to IHouse,
> ICateredHall, ISelfCateredHall, IHomeStay, or
> whatever, which each add extra features or
> constraints; or to go down some sort of adapter route.

In this particular case I would go with sub-classing, though usually I 
recommend the use of adapters. Basically, if the additional feature you try 
to implement has to do with the object's behavior in the system, it should be 
in an adapter. If the feature is characteristic of the object inside any 
system, it should be directly provided by the object.

> Regarding the Adapters route, in his book Phillip
> gives an analogy of Interfaces as a contract that an
> object uses to promise its functionality. If an
> Interface promises that an object will have a given
> method, does it have to provide it directly, or can it
> use an adapter to provide it?

If an object promises it provides an interface it has to do so directly, not 
via an adapter.

Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training

More information about the Zope3-users mailing list