Tuesday, May 12, 2015

Model-View-Presenter implementation in Android Development

I've written a simple example to demonstrate the implementation of MVP pattern in Android, here is the code

https://github.com/Ericliu001/AndroidSimpleMVP

which is inspired by this post:


http://philosophicalhacker.com/2015/05/08/how-to-make-our-android-apps-unit-testable-pt-2/

and Google's presentation:

https://www.youtube.com/watch?v=kilmaSRq49g





The goal is to move business logics out of Android Components such as Activity, Fragment, Service and place they in POJO java classes, which have no dependency on Android SDK, and these classes are called Presenters.

As a result, the Presenter classes are Unit Testable and less error prone.


The TestCase class MainActPresenterTest is included in the project to demonstrate how to test against the MainActPresenter class
There are 3 separate projects: one implemented in conventional way; one with MVP, one uses Eventbus as a part of MVP

No comments:

Post a Comment