MVVM Architecture || Beginners Guide || Android Coding

[et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

MVVM (Model – View – ViewModel) is a architectural design pattern for software development. MVVM architecture in android provides a better way of dealing with the components by making them loosely coupled.

In MVVM architecture every components has its own task to be furnished so they are faster as well.

MVVM architecture android :

Model :

Model deals with repository related components i.e., data may be from local database or remote api’s. Data is accessed from model and is passed on to View-Model for further processing business logic.


View :

View’s are the UI related components which mostly deal with Activity’s Fragment’s and their layout files, all together constitute to View.


View-Model :

The main business logic in the application is carried out in this module.Data is received from Model and processed accordingly and emits / exposes data which is observed by View.


Project Structure :

Project structure depicting MVVM architecture android

mvvm architecture android project structure


Data Binding:

Another key component with this pattern which makes the handling / accessing of UI components much faster, also avoid’s boilerplate code.

Data binding plays a vital role in app performance as initializing components and setting data to them with huge number of UI components is a time taking task.


Advantages :

  • MVVM architecture breaks the tight coupling between UI and business logic makes it easier for unit testing.
  • Design, development, data related components are purely independent so multi developers working on the project will have a good scope to work on individual components.
  • Using observers ViewModel is independent of the View.
  • Individual components make code re-usability and add up to app performance.
  • Maintenance of code is much simple, following a appropriate project structure.
  • Advanced components like LiveData add up to MVVM architecture providing lifecycle aware app transactions which reduces app crashes.
  • Memory leaks, app crashes are handled in this pattern.
  • Also the most happening scenario’s like outdated UI i.e., Activity or fragment not available at UI update after api call’s also handled by making use of life cycle aware components.


For more information on mvvm architecture android may refer this


If you have any queries on MVVM Architecture tutorial do let us know in the comment section below.If you like this tutorial do like and share for more interesting updates.


Show Buttons
Hide Buttons
Read previous post:
Runnable Interface || Thread in Java || Java example

  In the previous blog on Thread we have seen the implementation of Thread in java.In this topic Runnable interface...