Wednesday, August 1, 2018

Pure Model-View-Presenter in Android

It is quite complicated to find in the software development industry a standard in terms of architecture in Android development. It is true that, for some time, a very basic MVP has been proposed to break the God-Object (activities responsible for absolutely everything) and, since not so long ago, an MVVM proposed by Google, using its architecture components, is being adopted (ViewModel, LiveData, LifeCycleObserver…). Although these architectures (especially MVVM) fulfill the purpose of decoupling components and making them testable and reusable, we still find several points that make us ask ourselves if this is the best architecture we can use.

In the first case, the view and the presenter are known, as well as the presenter and the model. Regarding the MVVM, although the ViewModel does not know the view, the view does know the ViewModel, which makes reusing views with different ViewModels complicated. The principle of investment of dependencies (DIP) is respected only in one direction (view => service, and not service => view). This problem exists since an investment of dependencies in both directions gives us greater cohesion and less coupling, but also increases complexity. It is up to the reader to determine if this trade-off is worth it. 



from DZone.com Feed https://ift.tt/2v5dVeE

No comments:

Post a Comment