<div>Dear all,</div><div><br></div><div>I&#39;m trying out the Class Evolution features of Magma. Typically you want to have following stuff working: rename class, rename field, totally change internal structure of some part of the domain. You do this during development and have to make sure the data in production database gets converted to these new changes.  </div>

<div>I started by testing the &#39;rename class scenario&#39;: You have a running production system with a filled database containing objects of a certain type. During development, a class is renamed. The first thing I tried was to load the package containing the new class type (and not the old type anymore) in the production image. As promised on <a href="http://wiki.squeak.org/squeak/5602" target="_blank">http://wiki.squeak.org/squeak/5602</a>, under implementation, Magma recreates the old class definition in the production image. However, the objects defined in the database are not automatically converted to the new classes. (the rename of the class happened in the developer image, not in the production image); meaning that if you add new entries, objects of both class types will be in the database (which is bad).</div>

<div><br></div><div>To convert the old classes in database to the new classes, I tried the update strategies, as mentioned on <a href="http://wiki.squeak.org/squeak/5602" target="_blank">http://wiki.squeak.org/squeak/5602</a>. Working out the second option: one-shot script to enumerate all instances and populate, I followed these steps (my domain is about Productbacklogs, sprints and UserStories): </div>

<div><div><ul><li>Userstory &gt;&gt; various &gt;&gt; copy: UserStoryOld (make a copy of the old UserStory)</li><li>UserStory &gt;&gt; refactor class &gt;&gt; rename: UserStoryNew (give the UserStory the new name)</li><li>

UserStoryOld &gt;&gt; refactor class &gt;&gt; rename: UserStory (now you have a copy of the class definition of production with the old name)</li><li>write a script which converts all entries in the database using UserStory to UserStoryNew<br>

<br>UserStory&gt;&gt;asUserStoryNEW<br>   |result|<br>   result := UserStoryNew new<br>          businessvalue: self businessvalue;<br>   contents: self contents;<br>   title: self title;<br>   yourself.<br>   resterendeTijdenNodig do: [:each|<br>

           result addResterendeTijdNodig: each].<br>  ^result<br><br>and:<br><br>a script which iterates over all userstories in the database, creates UserStoryNew&#39;s from them, makes sure all links from and to the old UserStories are replaced by the new ones (for instance: put them in a productbacklog, replan them, ...); saving each of them again.</li>

<li>Load this package in the production image, run the script =&gt; all old entries are replaced with new classes. </li></ul><p>This approach works. It has the advantage that every change is committed, you can rollback to a commit point if something fails, and so forth. But it takes a lot of time to do such a simple change? Is this what is meant by a &#39;one-shot script to enumerate all instances and populate&#39; ? Is there another way of doing this change? Because it would mean that for every rename of a class you would have to write such a script.</p>

</div><div>A field rename can be handled in the same way. Let the old and new field coexist, a script iterates over all the objects, copying the old field to the new one. If it is just a simple type (Integer, Boolean or String), this will be simple again, however if this field is something complex with a lot of pointers from and to it, it will become somewhat more difficult to correctly write a convert script. But it will be possible.</div>

<div><br></div><div>According to the wiki there is also &#39;a faster one-shot script that operates directly on the MaObjectBuffers using MagmaFileTraverser&#39;. I looked into this, but I did not understand it. Any pointers how to, for instance, do a class rename using this technique?</div>

<div><br></div><div><br></div><div>Thanks for any advice,</div><div><br></div><div>Kind Regards,</div><div><br>Bart<br></div></div>
<br>-- <br>imagination is more important than knowledge - Albert Einstein<br>Logic will get you from A to B. Imagination will take you everywhere - Albert Einstein<br>Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Albert Einstein<br>


The true sign of intelligence is not knowledge but imagination. - Albert Einstein<br>However beautiful the strategy, you should occasionally look at the results. - Sir Winston Churchill<br>It&#39;s not enough that we do our best; sometimes we have to do what&#39;s required. - Sir Winston Churchill<br>