[squeak-dev] Trivial questions?

Colin Putney cputney at wiresong.ca
Thu Dec 31 15:40:01 UTC 2009


On 2009-12-31, at 6:58 AM, David T. Lewis wrote:

>> 2) How does one Data Migration in Smalltalk? I just know it from Rails,
>> where one has migrations, but how's that done in the Persistence layers
>> of some Smalltalk. E.g what happens if I add or remove instance
>> variables?
> 
> I don't know enough about Rails to understand the question, but in
> general it is straightforward to add and remove instance variables
> in Smalltalk.

Hi Friedrich,

David didn't understand the question because data migration is generally a non-issue in Smalltalk. When you add or remove an instance variable, the instances of that class are automatically migrated for you. There's a class called ClassBuilder that handles this as part of creating the new class. It builds the new class, locates all the instances of the old class, creates equivalent instances of the new class, copies instance state to the new instances and updates all object reference to point to the new instances. Finally, the old instances are discarded and available for garbage collection.

The one area where data migration does become an issue is when objects have been serialized and stored outside an image. Then reading them back into an image requires migration. There are various methods of doing this, and they tend to depend on the particular needs of your application. Of course, if you're using Gemstone, there's not much need to store objects outside an image. :-)

Colin


More information about the Squeak-dev mailing list