<br><br><div class="gmail_quote">On Thu, Mar 18, 2010 at 10:11 AM, Brent Pinkney <span dir="ltr">&lt;<a href="mailto:brent@zamail.co.za">brent@zamail.co.za</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Ahoy,<br>
<br>
I would like to contribute to this thread by explaining a problem that occurs often in telecommunications and logistics.<br>
<br>
It is common to have planning tools that allow the user to &#39;fork&#39; the master view of the &#39;domain model&#39; and make local changes to<br>
explore &quot;what ifs&quot;. Alas. the domain model is a directed graph of many thousands of instances, born of hundreds of classes, so<br>
duplicating all of this is not feasible.<br>
<br>
I have always wanted an object mechanism to detect &#39;copy of write&#39;, so that I might slay this pesky problem. If I had &quot;OCOW&quot;<br>
(Object Copy on Write), I could let the happy users work on the master object graph and manage the small portion that was changed<br>
by an such user experimentation. Obviously, there would need to be a nice exceptions or dependencies to wrap all this.<br>
<br>
<br>
My question (I really do not know) then is: does immutability, as proposed in this thread, help ?<br></blockquote><div><br></div><div>Yes.  For example take Alan Knight&#39;s GLORP framework which does object-relaitonal mapping.  How does one maintain the set of changed objects and the changes?  Mark the set of objects uploaded from the DB as immutable.  As each is first written to, trap the exception, take a shallow copy of the object and enter it into a dictionary mapping modified object to unmodified copy.  At commit time the modified objects are the keys in the dictionary and what slots have been modified can be found by comparing the unmodified copy with the modified current object.  The use of immutability here is an extremely beneficial optimization.  It avoids work, depending on what the base implementation is, e.g.</div>
<div><br></div><div>- avoids having to compare the entire object graph with the state of the database to discover differences</div><div>- avoids having to take a copy of the data set uploaded from the database (makes copying lazy)</div>
<div><br></div><div>cheers</div><div>Eliot</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<font color="#888888"><br>
Brent<br>
<br>
</font></blockquote></div><br>