Taxonomy Of Object Composition
|
|
As I wrote the last two entries, "Enhanced EJB" and "Fallacies of Inheritance", I noticed some parallels, that is the notion of acquisition, inheritance and delegation seem related.
So out of curiosity, I consulted the all wise google with a query "acquisition semantics prototype", hoping that it'll answer my question on the relationship between prototype based languages (i.e. Self, JavaScript) with the acquisition semantics found in Zope.
To my surprise, I encountered this research performed by the same people doing work on fluid AOP (i.e. CaesarJ). It turns out that they've already thought this out in detail and have created a taxonomy of the different "aspects" of object composition:
- Overriding - The ability of the modification to override methods defined in the base. In M(B), M's definitions hide B's definitions with the same name. Self-invocations within B ignore redefinitions in M.
- Transparent redirection - The ability to transparently redirect Bs this to denote M(B) within the composition.
- Acquisition - The ability to use definitions in B as if these were local methods in M(B) (transparent forwarding of services from M to B).
- Subtyping - The promise that M(B) fulfills the contract specified by B, or that M(B) can be used everywhere B is expected.
- Polymorphism - The ability to (dynamically or statically) apply M to any subtype of B.
inheritance object composition delegation mixin inheritance overriding x - x x redirection x - x x acquisition x - x x subtyping x - x x polymorphic - dynamically dynamically statically
Note: Delegation refers to prototype oriented inheritance.
They've written a compiler based on Kopi (GPL) that makes it easier to express different object composition semantics. Semantics that you possibly never knew existed. This just looks like a wonderful testbed to explore the pros and cons of composing object using varying kinds of semantics.
It could help answer the question of which composition mechanism is best for a particular domain. For example, is the Zope acquisition semantics, the very one that drives this blog, the ideal mechanism for composing Content Management Systems? Could there be a better alternative?
So head over there to download the thing, it's called "latte macchiato" and it'll keep you awake late at night exploring!

