Skip to content

(MVVM) Model View View Model

Devrath edited this page May 30, 2021 · 10 revisions

Improvement from MVC, MVP to a better Architecture

  • To overcome the drawbacks of MVC, MVP architecture modifications were done to segregate it to a better representation of architecture called Model-View-ViewModel.
  • It is one of the very popular ways of structuring the android code.
  • MVVM helps you to separate your code into many layers that let you have your own responsibilities.
  • Code becomes more readable, testable, maintainable.
  • The codebase stands the test of time.
Contents
MVVM block diagram
MVVM + Repository Pattern block diagram
Updates to view layer from view-model

MVVM block diagram

* `MVVM` handles the interaction between `view` and the `view model` in a specific way. * The `view-model` gethers the data from the `model` and provides to view in a specific way. * The `view` sends the events to the `view-model` and updates the `model`.

MVVM + Repository Pattern block diagram

* The `MVVM` can easily be upgraded with additional pattern such as `repository pattern`. * The repository helps to manage data from `local-databse` and `remote data-store`.

Updates to view layer from view-model

  • We can use live data to update the view from view-model.

Clone this wiki locally