Click or drag to resize
Data Synchronization

The ViewModel and the View each hold their own copy of the data shown on the View. Moreover, the ViewModel often also needs to duplicate at least some of the data provided by the Model. Data therefore needs to be synchronized between these entities. The following sections detail the responsibilities of the developer and suggest supporting classes.

Note Note

The developer responsibilities below should be read as suggestions rather than rules. For complex scenarios, it probably makes sense to implement things as suggested. In simple cases shortcuts can be taken, for example:

  • For a GUI that only displays data that never changes, it makes little sense to implement change propagation. It is sufficient to implement initialization.

  • For data that is only ever displayed and changed from a single view, change propagation from Model to ViewModel to View is unnecessary and does not need to be implemented.

This topic contains the following sections:

Initialization

Entity

Developer Responsibilities

Supporting Classes

Model

  • Implement property getters

ViewModel

  • Call property getters in Model

  • Implement property getters

View

Change Propagation from View to ViewModel to Model

Entity

Developer Responsibilities

Supporting Classes

Model

  • Implement property setters

ViewModel

  • Implement property setters

  • Call property setters in Model

View

Change Propagation from Model to ViewModel to View

Entity

Developer Responsibilities

Supporting Classes

Model

ViewModel

View