Introduction
In this repository, we are using the MVVM design pattern. Before going any further, you must first know what the MVVM design pattern looks like. Let's check!
Why MVVM?
MVVM separates your view (i.e. Activities
and Fragments
) from your business logic. MVVM is enough for small projects, but when your codebase becomes huge, your ViewModels start bloating. Separating responsibilities becomes hard.
MVVM with Clean Architecture is pretty good in such cases. It goes one step further in separating the responsibilities of your code base. It clearly abstracts the logic of the actions that can be performed in your app.
Note: You can combine Clean Architecture with the model-view-presenter (MVP) architecture as well. But since Android Architecture Components already provides a built-in ViewModel class, we are going with MVVM over MVP—no MVVM framework required!
Advantages
- Your code is even more easily testable than with plain MVVM.
- Your code is further decoupled (the biggest advantage.)
- The package structure is even easier to navigate.
- The project is even easier to maintain.
- Your team can add new features even more quickly.
Our data flow will look like this:
Our business logic is completely decoupled from our UI. It makes our code very easy to maintain and test.