Data Moving Plug-in: Client-Server Synchronization

<< Back to Data Moving Plug-in Main Features

When using Client-Side techniques we are faced with the problem of synchronizing the Client-side ViewModel with the server. Parts of the Client-side ViewModel are usually mapped to UI elements such as Client Controls or simple Html elements. Typically, a single update sent to the server is composed of data connected to several controls; we call Workspaces, the sub-parts of the Client-side ViewModel that are sent to the server together in a single “batch”. A Workspace, in turn, is composed of two conceptually different sub-parts: a kind of short living data structure that is used just to carry out the current task and a set of long living data structures that are typically connected with a Database on the server side. Typically, on the client side, we don’t have all long living entities  of a “given type” but just a small window of the whole Entity Set. We call Entity Set Window, a set of all long-living entities of the same type stored in the Client Side ViewModel, and we call Core Workspace the part of the Workspace that remains after removing all Entity Set Windows.

Instances of the updatesManager class take care each of a different Entity Set Window by computing the changes-sets of their Entity Set Windows(insertions/deletes/modifications) and by inserting them into the Workspace to be sent to the server. The whole process is completely automatic, and requires no programming effort. Also the updatesManager instances are created automatically if their Entity Set Windows are bound to Data Moving Plug-in controls.

Each Workspace may have also a Whole WorkSpace updatesManger that handles the Core Workspace. A single Master updatesManager instance takes care of coordinating the job of all other updatesManager instances, and the job of communicating with the server, typically it is a Whole WorkSpace updatesManger if there is one.

The only programming effort required to the developer is just declaring the Master updatesManager instance , and passing it the list of all other instances to be coordinated. Once this is has been set-up it is enough to call the update method of the Master updatesManager instance to trigger the whole operation of preparing the Workspace and sending it to the server. 

Once the server receives a Workspace , it processes it, and prepare the response for the client with a few calls to pre-defined Data Moving Plug-in helper classes. The response may contain errors to be dispatched to adequate places in the User Interface and/or information on principal keys created on the server side and/or Remote Commands to be applied to the Core WorkSpace on the client side.

The Master updatesManager instance dispatches both the principal key information and the errors to the various updatesManager instances that have the responsibility to handle them, and then it executes the   Remote Commands. The whole process is completely automatic and doesn’t require any programming effort.

Remote Commands enable the developer to modify the Workspace without substituting it. In fact, often a complete substitution is not possible because a similar substitution would  break all connections the Workspace might have with UI elements and other data structures.

An example of Client-Server Synchronization is discussed  here.