The MVVM Pattern
The Model-View-View Model (MVVM) pattern is a common way of structuring a UI application. It uses a data binding system that helps move data between its view and view model parts. This means it achieves separation of application logic (view model) from the display of the UI (view).
Separation between the application logic and the business services (model) is commonly achieved by a Dependency Injection (DI) system.
MVVM might be overkill for a simple application; but as applications grow over time, they will often reach a point where keeping display definition and application logic in the same UI component modules becomes a problem:
- Interactions between UI components become complicated and error-prone.
- It becomes difficult to unit test UI components due to dependencies on the target UI platform.
MVVM solves this by abstracting the application logic into code-only classes that do not depend on the target UI platform, and can therefore be unit tested independently.
To discover more about the background to the MVVM pattern, see the Microsoft Patterns and Practices article here.