I'm learning about MVVM and Clean Architecture. Then I found some articles present about MVVM + Clean Architecture, but I still didn't get it about the difference between mvvm with clean architecture and mvvm without clean architecture. Any summary about these stuff? Thank you.
Advantages of Using Clean Architecture 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.
Clean architecture is a method of software development in which you should be able to identify what a program performs merely by looking at its source code. The programming language, hardware, and software libraries needed to achieve the program's goal should be rendered obsolete.
References — In MVC, the View doesn't have reference to the Controller while in MVP, the View has reference to the presenter and in MVVM, the View has reference to the View-Model. Entry Point — For MVC, the entry point to the application is the Controller whereas, for MVP and MVVM, the entry point is the View.
Model — View — ViewModel (MVVM) is the industry-recognized software architecture pattern that overcomes all drawbacks of MVP and MVC design patterns. MVVM suggests separating the data presentation logic(Views or UI) from the core business logic part of the application.
Clean architecture aims to separate the layers. Business Layer, Data Layer and Presentation Layer will be separate applications. Therefore you will increase the reusability for each one of them. MVVM as design pattern should be implemented in the Presentation Layer. Presentation Layer will interact with Business Layer (or Domain Layer) and the Business Layer will use Data Layer for sharing data.
MVVM is just part of the clean architecture in the presentation layer
. It just a set of rules on how to display the data from UseCase.
One of the benefits of using clean architecture is we can change our design pattern in presentation layer
without changing domain layer
or use case.
So for example, if we're using let say MVI and then changing to MVVM, it can be done smoothly with ease.. :)
MVVM is just a technique to manage the View layer of whatever architecture you're using.
Clean Architecture is a way of organizing communication between layers. They aren't mutually exclusive
The Layers of MVVM with Clean Architecture The code is divided into three separate layers:
Presentation Layer
Is here, where the logic related with views and animations happens. It uses Model-View-ViewModel ( MVVM), but you can use any other pattern like MVC or MVP
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With