Android MVVM Architecture in Java

What is MVVM Architecture

MVVM
The purpose of this blog is to provide an introduction to the Model-View-ViewModel pattern. this design pattern is introduced by Microsoft because of the WPF Application. To understand the MVVM design pattern you no need to know about the WPF Application. but you want to have some basic knowledge about OOP. 

M-Model
V -View
VM - ViewModel

M- Model 
Actually Model is a class that represents a Structure or Domain of the database. we will look at an example to understand. A database consists of a Table called UserInfo. Which table contains columns below userId, id, title, and body So in our model class will represent the above columns as the Class variables.


According to your needs Construture, getters, and setters also come with the class.


V-View
Whatever you see in your screen(UI) example as Trextviews, edit text, radio buttons and etc.
  • The View only talk to the ViewModel
  • The view will not talk to the Actual model




VM-ViewModel
Provide the data to the UI and keep tracking different state changes of the view.
  • ViewModel will not responsible for making the request to the web services.
  • ViewModel will not responsible for accessing the database.
  • ViewModel will talk to the view.
 



I provide the Android MVVM example with Retrofit this link you will cover the Singleton design pattern too https://github.com/prasath95/Android-MVVM-Architecture-Java 

Comments

  1. Experience is the name everyone gives to their mistakes.Knowledge is power.Keep it up bro☑️🔝

    ReplyDelete

Post a Comment