On 04.08.2010, at 09:28, Pat Maddox wrote:
> Simple example: I create a Person class that has one instance variable named 'name'. I've created a few instances and put them in a collection "Person allPeople". Now I change Person's definition to have the instance variables 'firstName' and 'lastName' and remove the instance variable 'name'.
>
> The Person instances I have now have instance variables 'firstName' and 'lastName' set to nil.
>
> When I'm developing locally it is okay (if irritating) for me to wipe out any objects that I have in memory and start again. More importantly, I don't have the first clue how I'm going to deploy code and keep it up to date. I can get the new code in via Monticello, but what good is that if it wipes out all of my data?
>
> I feel stupid asking because I'm sure there's some aspect I'm missing, but please help me out here because I'm not seeing it.
>
In pharo every object has a class. If you change the class all of the objects are migrated towards the new class. Your use case is indeed a difficult one. I assume that in name you have first and last name combined. This scenario mostly means you need a two-step change. Usually you would scan all of your instances and you would create some method (splitName) that can split the name into firstName and lastName. The next step would be to add that method and the instance variables firstName and lastName to your class. In a monticello package you can have something executed after installation. That be something like
Person allInstances: [:each| each splitName]
Now you would have three instance variables all filled with values. In the next monticello upgrade you can remove the instance variable name from the class safely. Well, you could have the code the splits the name also to remove the instance variable. But if you are feeling insecure the two-step approach is good.
Hope this helps,
Norbert
_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users