Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Effective Android Development using MVP

Effective Android Development using MVP

In this presentation we talk about the effective way of developing android application using MVP.
The difference between old-school Android MVC and MVP.
We further discuss the benefits of MVP, walk through the UML diagram for Sample app and share the Github link with you.

Pratyush Kshirsagar

May 27, 2016
Tweet

More Decks by Pratyush Kshirsagar

Other Decks in Programming

Transcript

  1. What is MVP? • MVP stands for Model-View-Presenter, is an

    architectural pattern to design the user interfaces. • Model - is an interface representing the data to be displayed. • View - displays data and responds to user actions. • Presenter - is a mediator and performs action on model and view.
  2. Current Scenario - Android Design • In the current scenario

    the xml layouts represent the views, the activities/fragments act as controller and the the POJO’s are the models. • Unfortunately not much can be done in the XML layouts and thus controller i.e. the activity or fragment need to take care of data binding, user inputs, animations, business logic, etc. • So, as the project grows and evolves, the controllers become complex and monolithic, eventually turning into god objects. Thus the code is hard to read, debug, test and refactor.
  3. MVP to rescue MVP facilitates speed and product quality -

    MVP helps us to maintain the product quality and sprint velocity by keeping the code simple, maintainable, decoupled and testable. Focus on business logic - MVP separates the low level android view operations by forcing it into the view and putting all the business logic in the presenter.
  4. MVP to rescue Separation of Concern - Each component in

    MVP has a purpose with specific set of actions to perform and do not bother about the intricacies of each other. Thus, achieving separation of concern. Almost Test Ready - because the components are decoupled but interconnected, it’s easy to determine the testing framework and type of tests to be written. We can write clean and fast JUnit tests for Presenter and Model, can use JUnit/Robolectric for Views.
  5. Summary • Separate the business logic by moving it to

    a presenter. • Always test your presenter and make sure it is independent of any view related code. • Attach or detach the presenter or keep it persistent on configuration changes. • Activities and/or Fragments should implement the view interface. • Android MVP Sample - Github