Slide 1

Slide 1 text

Model-View-Presenter(MVP) Pattern for Android Raka Westu Mogandhi Brownbag Onebit Friday July 31th

Slide 2

Slide 2 text

What is MVP? Software design pattern on Android that separates presentation layer from logic.

Slide 3

Slide 3 text

MVP vs MVC ● MVP Pattern – View is more loosely coupled to the model. The presenter is responsible for binding the model to the view. – Easier to unit test because interaction with the view is through an interface – Usually view to presenter map one to one. Complex views may have multi presenters. ● MVC Pattern – Controller are based on behaviors and can be shared across views – Can be responsible for determining which view to display

Slide 4

Slide 4 text

MVP Structure

Slide 5

Slide 5 text

Why use MVP? ● Makes view separated from data source → code is easier to scale and maintain. ● Makes testing approach easier.

Slide 6

Slide 6 text

Examples ● https://github.com/onebithq/MvpTemplate ● https://bitbucket.org/onebit/wobe-mvp

Slide 7

Slide 7 text

Future Implementation ● RxJava/RxAndroid usage to manage data flow. (Example: https://github.com/zsiegel/rx-mvp-android) ● Separate model layer using UseCase/Interactor-Repository Pattern – Repository → Get data from data source (network, database, etc.). – UseCase/Interactor → Get data that will be used on presenter from repository. ●