[Seaside] Changing object class

Sebastian Sastre ssastre at seaswork.com
Wed Oct 3 12:24:25 UTC 2007


Smalltalkish how we function so..

First of all it's really rare to have a real need of changing one object in
place of another so I'll convice myself about other simpler options like
instantiation.

Do you need to preserve identity of the objects or data is enough?

If data is enough you can make:

	SomeThing>>asOtherThing

		^ OtherThing fromSomeThing: self


	OtherThing class>>fromSomeThing: aSomeThing

		^ self new
			prop1: aSomeThing prop1;
			prop2: aSomeThing prop2;
			...
			yourself

	that is enough?

Sebastian Sastre
PS: if identity is a must then you should investigate the #become: message


> -----Mensaje original-----
> De: seaside-bounces at lists.squeakfoundation.org 
> [mailto:seaside-bounces at lists.squeakfoundation.org] En nombre 
> de Oleg Richards
> Enviado el: Miércoles, 03 de Octubre de 2007 05:38
> Para: seaside at lists.squeakfoundation.org
> Asunto: [Seaside] Changing object class
> 
> Hello Guys!
> 
> Following question (maybe its a little bit "smalltalkish"):
> I have an object - an instance of RowNumeric class. I also 
> have 2 classes derived from this class. Can i change instance 
> class from one derived to another without touching instance variables.
> 
> So i have RowNumeric with all needed variables. And now i 
> want to convert some numeric rows to total ones.
> 
> Cheers, Oleg
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



More information about the Seaside mailing list