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

MVP and MVVM

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

MVP and MVVM

Avatar for Raj Suvariya

Raj Suvariya

March 18, 2018

Other Decks in Programming

Transcript

  1. WHAT IS MVP? ➤ Definitely not Minimum Viable Product ➤

    Full form of MVP is Model View Presenter. ➤ M - Model (Models representing data) ➤ V - View (Activities, Fragments, Custom Views) ➤ P - Presenter (Mediator) ➤ It’s an structure for writing Android Applications. ➤ It provides separation of concerns, reusability, testability, abstraction of data layer.
  2. WHAT’S WRONG IN MVP? ➤ It has 1 to 1

    tight coupling with View and Presenter. ➤ It has a lot of boilerplate code. ➤ We need to manually handle device state changes.
  3. WHO COMES TO RESCUE? ➤ MVVM. (Event driven structure) ➤

    M - Model (same as MVP) ➤ V - View (same as MVP) ➤ VM - ViewModel (all the UI logic goes here) Source : https://labs.ribot.co.uk/approaching-android-with-mvvm-8ceec02d5442
  4. MVP VS MVVM ➤ Unlike MVP , MVVM doesn’t hold

    reference to the View. So the tight coupling between View and Presenter is gone. ➤ In MVVM ViewModel provides the data without knowing who is going to consume it. So in MVVM View -> ViewModel relation can be 1:many while MVP has 1:1 relationship. ➤ Less boilerplate code. ➤ ViewModel handles device state automatically :). ➤ Views are easily testable using Expresso, and ViewModel and Models are easily testable using JUnit.
  5. CHEAP PUBLICITY ➤ Github: http://github.com/ rajsuvariya ➤ Twitter : https://twitter.com/

    RAJ_SUVARIYA ➤ Medium : https:// medium.com/@rajsuvariya ➤ E-Mail ID : [email protected] ➤ Linkedin: https:// www.linkedin.com/in/ rajsuvariya/