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

James Allwyn jamesallwyn at yahoo.co.uk
Wed Aug 10 14:01:52 EDT 2005

Hello list,

We are in the process of building a web service for
the local University, to allow accommodation to be
listed, and students to search for it.  I’ve hit a
conceptual stumbling block about how we should be
proceeding with arranging this.

So far we have built a system with IProperty and
IPropertyFolder to contain the Property objects.
Property objects themselves can contain various items
(such as images, Advert objects, and AttributeSets,
which define various sets of information you might
want to store about a property).

The stumbling block I have hit is how to generalise
this to different types of accommodation? Whilst, for
example, it may be relevant to describe whether a
house has a washing machine or microwave in its
kitchen, for a catered hall of residence it would be
more suitable to describe whether it has an on site
bar or gym. We are also creating an amenity-based
rating system, which I would like to be consistent
across all sorts of accommodation – naturally,
different types of accommodation will have to be
judged against different criteria, but I would like to
be able to call the same method for whatever type and
get a valid result, just calculated in different ways.

There are three or four quite distinct types of
accommodation, which will have differences, but there
will also be similarities (e.g., able to store images
for each, able to rate each, able to add adverts for

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.

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?

Thanks in advance,

Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

More information about the Zope3-users mailing list