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

MVP: From Android to Java

MVP: From Android to Java

Slides from my talk at DevFest New Delhi 2016 on MVP architecture in Android

Kshitij Aggarwal

October 08, 2016
Tweet

More Decks by Kshitij Aggarwal

Other Decks in Programming

Transcript

  1. .. but isn’t it called MVC !? Android uses MVC

    (Model View Controller) at its core Pros: - Responsibility delegation Cons: - Scalability - Modularity - Testability
  2. What good is MVP then!!? Pros: - Separation of concerns

    - Modular - Scalable - Testable Cons: - Slow development speed
  3. Separation of Concerns Each layer in MVP are bound by

    a ‘contract’ Model & View Layers never communicate with each other directly View layer is completely passive Android API’s are bound to the View Layer Model & Presenter are pure Java code Functionality of each layer is bound & limited to perform specific tasks, which makes it easier to find and fix issues
  4. Modularity Packages are not made for components but for screens

    Every screen is in its own package containing the Activity/Fragment (View), Presenter & Contract With each screen having it own package and business logic, its easier to modify or add new features with minimal collision
  5. Scalability Access to the Model Layer is given in data

    repository format Model layer is not bound to any contract hence making it accessible to all parts of the app With all parts of the app placed under specific boundaries, modifications or new updates pose minimal impact on existing peices
  6. Testable 80% of the code in MVP resides in Presenters

    or Model layer. Easier to write tests as the complete app is broken to down to smaller fixed modules Since Model & Presenters are pure Java, they can be easily tested using only jUnit Overall increase in testing speed since jUnit tests are faster than Espresso and other Android Tests