Tuesday, January 25, 2005

Document Version Control

From the previous post, we know Call-by-Reference is great for online access. Then how do we handle conflicts? This problem is actually everywhere. The scenario is: user A reads a document at t1; user B reads the same document at t2; user B modifies the document and saves it; user A modifies the document, saves it and thus overwrites user B's changes.

The solution seems to be a best practice that many have adopted (Hibernate, Confluence): use a version number. User A saves the document saying these are the changes on top of version 1. But the current version is already version 2 (with user B's changes). So user A either fails or is prompted with differences (as is the behavior of Confluence) to merge.

What does this mean for us?
  1. We want to keep the unit of documents small to reduce chance of conflict.
  2. We want to implement a structural diff that can show visually the differences, not just diff tool's textual differences.
  3. Our approach of model changes works perfectly well here: any new document is created by applying model changes to its previous version.
Then what about offline mode when Call-by-Value has to be used? Fortunately, the same approach can still be used. The changes sent back to the server is nothing more than a list of model changes on top of a certain version n. If the current version is n, we can apply the model changes directly; otherwise, we prompt the user to merge the differences. Exact same implementation as that in the online mode. How beautiful!

0 Comments:

Post a Comment

<< Home