본문 바로가기
Weekly/Kotlin Weekly

Kotlin Weekly 191

by ksb0511 2020. 3. 31.

Android Best Architecture = MVI + LiveData + ViewModel

 

Best of MVVM and MVI architecture patterns merged into one, for a perfect architecture for any Android project.

 

1. Separation of concerns : It is a design principle for separating a computer program into distinct sections such that each section addresses a separate concern.

 

2. Drive UI from a model

 -> MVC : Model-View-Controller / It is the base of all modern architecture patterns. Model is responsible for managing the data of the app. It receives user input from the controller. Controller's role is very busy. Controller responds two functions. The two functions mean what user input and performs interactions on the data model objects.

 

 -> MVVM : Model-ViewModel-View / View has the instance of ViewModel and it calls respective function based on the user input/action. As I know it, ViewModel has LiveData. So, View can recognize data's changes. In other words, View observes different observable properties of ViewModel for changes.

 

 -> MVI : Model-View-Intent / View exposes view-events and observes model for view-state changes. This Architecture's data flows have only one direction. 'View -> Intent -> Model -> View'

 

In summary, the best part of MVVM is ViewModel(Because it is very efficient). But ViewModel's properties like multiple observable can cause state overlapping issue. This issue is solved by MVI architecture. MVI pattern solves this problem by adding an actual 'Model' layer which is observed by view for state changes.

'Weekly > Kotlin Weekly' 카테고리의 다른 글

Kotlin Weekly 186  (0) 2020.02.25
Kotlin Weekly 185  (0) 2020.02.23

댓글