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

Jean-Marc Orliaguet jmo at ita.chalmers.se
Fri Aug 12 09:07:33 EDT 2005


Hi!

concerning subclassing vs adapting, these are really different things,
arent' they?

my understanding (from a semiotic point of view) is that subclassing is
about the classification of objects (taxonomy), and that adapting is
about the representation of objects.

subclassing
a car is a vehicle, the class of cars is a subclass of the class of
vehicles, and so on. The difficulty is in defining categories of
objects, in the conceptualization (what is a "user", what is a "group",
what is a "container", what is a "page", what is a "portlet" ... ?) and
in relating the concepts together. That takes a lot of time, unless your
concepts are already very well-defined. Once you've defined your
concepts, you cannot change them because all concepts derived from them
will be changed too.

adapting
here you are re-presenting something, you are not dealing with the
original object at all, you are dealing with a representation of the
object. Say an actor is representing Hamlet, when doing a theater
adaptation of the piece, the original character "Hamlet" is not changed.
Since you are not changing the object being adapted you can do many
different adaptations (TV, theater, novel, etc). Views are typically
adapters, they are the sign of the object being adapted, they are
different representations of the same thing.

annotations
this is metadata, information about the object. That's also a
representation of the object, although its stored on the object itself
(creation date, author, etc).  I suppose that you store there
information that cannot be computed directly from the object. Otherwise
you'd use an adapter (ISize, etc.). You wouldn't store the size of an
object as an annotation.

What I don't like about annotations is that the information is stored on
the object itself. That's why I'm using relations in cpsskins
(http://svn.nuxeo.org/trac/pub/file/z3lab/cpsskins/trunk/storage/relations.py)
instead of using annotations even for trivial things such has whether an
object is visible or not.

If metadata is "external" information about the object, a sum of
knowledge about the object then it should not be stored on the object
itself, although it's clear that it pertains to the object. But what
happens when you are storing a relation, say "object X __ has style ___
Y " ? is the style metadata?  NO it's not, it is just that the object is
in relation with another object (a style) and the relation (a dyadic
relation) is external to *both* of them.

Even for monadic relations (X __ is visible, X __ has expired), the
relation is *external* to the object.

So instead: every object has a unique id (IntId) and the relations
between the objects are relations between object ids, which means that I
can modify the relations between the objects without changing the
objects themselves.

This is why I believe that annotations are like adapters all about
representation and if adapters are kept separate from the object being
adapted then annotations should be kept separate too.

/JM





More information about the Zope3-dev mailing list