Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

android

What is MVVM in Android?

Fahad Farid

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

MVVM -Model, View, ViewModel- is an architectural pattern that allows for quick design changes.

  • Model: Data for the application – it cannot directly talk to View.
  • View: Represents the UI of an application.
  • ViewModel: A link between the Model and the View – it transforms the data from a model into data streams and forwards it to the View.

The illustration below explains this model:

svg viewer

There are two ways to implement MVVM in Android:

  • Data Binding
  • RXJava

Pros and Cons

Pros:

  • MVVM facilitates the parallel development of a UI.

  • MVVM abstracts the View and reduces the quantity of business logic required.

  • The ViewModel can be easier to unit test than event-driven code.

  • The ViewModel can be tested without concerns of UI automation and interaction.

Cons:

  • For simpler UIs, MVVM can be overkill.

  • Data bindings can be harder to debug than imperative code.

  • Data bindings in nontrivial applications require a lot of logs.

  • In larger applications, the ViewModel can be more difficult to design.

RELATED TAGS

android

CONTRIBUTOR

Fahad Farid
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring