Changing the class of an instance

Roel Wuyts Roel.Wuyts at ulb.ac.be
Wed Nov 12 13:34:25 UTC 2003


You can do a 'become' operation, or a become in one way. Looking for 
selectors with become in their name will get you there.

But in your example it might be better to implement a State design 
pattern if you frequently need to do that and objects can be in a 
certain state. Especially since it seems a key part of your design 
(from the few lines I read :-) ). See the Design Patterns companion for 
Smalltalk to have a more detailed discussion on this and the relation 
to the become operation.

On 12 Nov 2003, at 14:01, Giovanni Corriga wrote:

> Hi
>
> Is there a way to change at runtime the class of an instance?
>
> In my application, XPSwiki (http://www.agilexp.org/XPSwiki) I need to 
> be
> able to delete a page. Since a great part of the organizational
> functionalities of the tool depends on the class of the single pages
> (Task, UserStory etc), when deleting a page I need to change its class
> from i.e. UserStory to DeletedPage.
>
> Do you have any suggestion on how I can implement this?
>
> 	Thanks
>
> 		Giovanni
>
>
Roel Wuyts                                                              
   DeComp
roel.wuyts at ulb.ac.be                               Université Libre de 
Bruxelles
http://homepages.ulb.ac.be/~rowuyts/                                    
Belgique
Board Member of the European Smalltalk User Group: www.esug.org




More information about the Squeak-dev mailing list