MVVM
MVVM allows you to separate the UI and business logic. When you need to redesign the UI or update the Model/business logic, you only need to touch the relevant component without affecting the other components of your app. This will make it easier for you to add new features and test your existing code. MVVM is also useful in creating huge applications that use a lot of data and views.
With the MVVM architectural pattern, your application will be grouped into three components:
- Model: Represents the data layer
- View: The UI that displays the data
- ViewModel: Fetches data from the
Model
and provides it to theView
The MVVM architectural pattern can be understood better through the following diagram:
The Model contains the data and the business logic of the application. The activities, fragments, and layouts that your users see and interact are the Views in MVVM. Views only deal...