in reply to Instance data inheritance?
If you have a case where MyClass::Item ISA MyClass, then you can rebless the object into the subclass. I'm using that technique right now on a project.
In my case, I have a set of fairly closely coupled classes (and that coupling is reasonable in this case). The parent class carries the data used all over the place and the subclasses carry more task specific data. As the object (and it could well be a Singleton) gets passed from one phase to another, it gets reblessed into the class that encapsulates the phase specific state and behavior.
This may not be the best structure, but it has fallen out rather naturally as I grok this ball of mud I've inherited.
In my case, I take care to capture the previous class and (effectively) localize the class change to the phase in question.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Instance data inheritance?
by merlyn (Sage) on May 16, 2005 at 14:13 UTC | |
|
Re^2: Instance data inheritance?
by blazar (Canon) on May 17, 2005 at 07:41 UTC | |
by herveus (Prior) on May 17, 2005 at 10:40 UTC | |
by blazar (Canon) on May 17, 2005 at 14:04 UTC |