The lesser known MVVM

Akash Shyam - Feb 21 '21 - - Dev Community

What is MVVM

MVVM combines the advantages of separation of concerns provided by MVP, while leveraging the advantages of data bindings. The result is a pattern where the model drives as many of the operations as possible, minimising the logic in the view.

Components of MVVM

View

The view represents the data and informs the model-view about the users actions. The view holds a reference to the model view.

The view model is an abstraction of the view exposing public properties and commands.

Model View

The model view exposes or shows relevant parts of the available data to the view. The model view can be used for many views like a many-to-one relationship. So, the model view is ignorant of the view that is using it.

The view model is an abstraction of the view exposing public properties and commands.

Model or Data Model

The model gets or saves the data, prepares the data and sends it to the model view.

Model refers either to a domain model, which represents real state content (an object-oriented approach), or to the data access layer, which represents content (a data-centric approach)

A simple diagram to understand better

Alt Text

Some Disadvantages of MVVM

  1. Can be overkill in small and simple applications
  2. Generalising the view model upfront can be difficult
  3. Large-scale data binding can lead to low performance

Do share your views in the comment section. The next post is probably about MVP

. . . . . . . . . . . . . . . . . . . . . . .