DiffGram based updates

DiffGram based updates

Old forum URL: forums.lhotka.net/forums/t/7511.aspx


RockfordLhotka posted on Wednesday, August 26, 2009

From time to time the question comes up about doing save operations, and whether sending the entire object graph to the server (and back) is the optimal solution.

That's the default behavior of the data portal, and it has some major advantages, since the business rules in your business objects can run on client and/or server and you know they'll work since the object graph is intact in both places. This makes coding very simple and increases reuse of your business rules.

However, it is true that sometimes you can have a large object graph where only a small number of objects change, and sending the entire object graph roundtrip isn't ideal. If your business rules are simple and don't span multiple objects in the graph, it can be realistic to consider sending only the changed data roundtrip, not the object graph.

This is called a diffgram (or datagram). It means that the server-side code doing the update does not have access to the object graph, only the changed data, and so it can complicate your code and make reuse much harder. But it can also radically reduce the amount of data on the wire in some cases.

The new Csla.DiffGram sample application (and library) in svn://svn.lhotka.net/csla/samples/trunk/CslaNet/cs shows how to do this with relatively little effort. This sample includes an actual Csla.DiffGram project that provides framework support for the concept, along with a sample UI, business layer and app server to show the basic operation.

This sample will be part of the next 3.8 samples release, or you can grab it from svn directly.

Copyright (c) Marimer LLC