[PEAK] Jumping Aspects

Phillip J. Eby pje at telecommunity.com
Sat Jul 31 11:30:57 EDT 2004


At 11:02 PM 7/30/04 -0700, Robert Brewer wrote:
>Phillip J. Eby wrote:
> > ...what if we just changed the object's class on-the-fly?
> >
> > It seems sort of weird, but basically what would happen is
> > that if you called someObject.setFoo(42), then there would
> > be some functions getting called to do DB-specific or UI
> > operations, following which the __class__ of 'someObject'
> > would change to the abstract domain class, and the original
> > "abstract" setFoo(42) would execute.  Finally, the class
> > would return to being the workspace-specific class.
>
>Q: What would be the drawback of the workspace-specific class possessing
>[a reference to] the abstract class rather than _becoming_ it? Has-a
>versus is-a.

The class doesn't "become" anything.  The instance's __class__ will change 
to point to a different class whenever the set of applicable advice changes.

Think of it as the Strategy pattern, but implemented by actually changing 
the object's type instead of delegating to a type-like object.




More information about the PEAK mailing list