Model-View-ViewModel: A simple example
MVVM is an application design pattern often used in user‑interface programming. It provides a structure for organising applications that is particularly useful when multiple views need access to the same underlying data.
MVVM defines the following components:
- Model
- Provides access to the underlying data that should be displayed. This can be a direct reference to the data, or mediated by a data‑access‑layer (e.g. an ORM).
- View
- Responsible for actually drawing the contents onto the screen. It displays a representation of the Model, receives user-input, and forwards the handling of these events to the ViewModel.
- View Model …