Thursday, January 9, 2003

Aggregation versus Inheritance
EuroPython had an interview with Jim Fulton (I can't determine the date, but I'm guessing some time within the past year), in which he gives a good summary of Zope 3's differences over Zope 2 (I've been looking for such a summary):

Zope 3 moves Zope from an inheritance-based framework to a component-based framework. Complexity is managed by splitting responsabilities among many cooperating components, rather than many cooperating mix-in classes. Components are connected using interfaces, which also provide component specification and documentation.

Some other big ideas:

  • It should be possible to use existing Python objects in Zope with little or no change.
  • Applications can be customized by adding, changing, or removing components.
  • Site configuration is done by site-managers or deployment specialists without modifying code.
  • Many CMF technologies will be part of the core.
  • Acquisition and namespace lookup is wildly more explicit.
I could go on, but I won't.

"Cooperating components instead of cooperating classes" could still be seen as an ambiguous phrase. I think developers who are steeped in component models and aggregation would understand it. But what about those who are used to the static overbearing inheritance model?

I guess it could be summed up as "Zope 2 excepts you (you being an object in the Zope system) to provide it lots of information and functionality all by yourself. Zope 3 looks for people to help you".

In Zope 2, if you got annoyed that a particular didn't implement the obscure little method to display sizing information in the ZMI, there wasn't much you could do about it without monkey patching.

In Zope 3, you write an adapter for that object that implements the ISized interface, register the adapter, and voila! One little object helping another.

By developing services to query for adapters (saying "I've got Frank here, can anyone tell me how tall he is?") instead of expecting behavior directly from an object, new doors to interoperability and speciality open up. Susie pops over and says "Why I can tell you, I've got measuring tape right here! He's 5 feet, 11 inches tall." Of course, Frank can say "I can tell you" and report his tallness himself, but he's a busy man and knowing his height at all times just might not be something he needs to do on a daily basis.

Of course, if Susie can be replaced with a robot or some other machine or person that can perform the same job (measure how tall people are), she can be replaced without bringing down the system. Frank's genetic algorithm can't be replaced (easily), so if he's suddenly unable to report his height correctly, he's useless in this situation without someone to help him adapt.

Hmm.
2:37:38 PM  blips[]