Re: Change subclass at runtime ?
Chuck Hill <[email protected]> Mon, 21 Jun 2004 11:05:51 -0700
| Newsgroups | gmane.comp.web.webobjects.eof |
|---|---|
| Message-ID | <[email protected]> |
You can call forgetObject() after doing this and then refetch it (not fire a fault!). I've done this is desperation a few times but it is NOT something that I'd want to reccomend for production code. What you need to do is to change your design so that the different data / behaviour is in other objects. Then, rather than change the class, you just change which object a relationship points to. There is a name for this pattern, but I forget which now. Delegate perhaps? Or State? Chuck On Jun 20, 2004, at 9:42 AM, Dominique Schoenenberger wrote: > I have inheritance in my application and sometimes I have to change > the subclass of a record. How to do that ? > > It is vertical inheritance so in theory, you have to change the class > discriminating attribute in the database but if you do this at run > time, the class may be already instanciated... do I have to refault > the object ? and what about relationship ? > > One of my solution to this problem is to create a new object of the > class we want to change to, copy all values of the properties of the > old object to the new one and then delete the old object. This is a > solution but it is much more complicated than changing the > discriminating attribute... > > Anybody having already found something for this ? > > Dominique > > _______________________________________________ > EOF mailing list > [email protected] > http://www.omnigroup.com/mailman/listinfo/eof