Model-view-view-model is a presentation-oriented architectural style used in modern UIs.

Components

  • View
    • Renders the UI, and interacts with the UI and reacts to UI state changes
  • View model
    • Holds UI state and logic as well as adapts model data for the view
  • Model
    • Business logic and data access
  • The connectors here are user events and UI state

Pros and Cons

Pros:

  • Separation of concerns for the UI, where rendering is separated from the UI state logic
  • Views can be destroyed and recreated without framework dependencies
  • One view model can drive multiple view variants Cons:
  • Overkill for simple UIs
  • Reactive flows and state propagation can be harder to trace

Variants

  • Model View Controller Model View Presenter
  • The presenter is an explicit adaptor between the view and model.