MVVM vs MVP

52d6b8fd288036707ddd50eb6f595cb7?s=47 Aydar
October 10, 2017

MVVM vs MVP

Presentation for the lightning talk on spikeweek at Freeletics

52d6b8fd288036707ddd50eb6f595cb7?s=128

Aydar

October 10, 2017
Tweet

Transcript

  1. MVVM-C vs MVP Aydar Mukhametzyanov Dmytro Khmelenko

  2. None
  3. None
  4. View Controller Model Model-View-Controller

  5. Layout Activity View Controller Model Model-View-Controller

  6. View Controller Model Model-View-Controller

  7. UIViewController Model View Controller Model-View-Controller

  8. Problems with MVC Activity/UIViewController is a “God” class Business logic

    is mixed with UI Hard to reuse Hard to implement tests
  9. Solution Model-View-Presenter Model-View-ViewModel (+Coordinator)

  10. View Model (Interactor) Activity Layout Presenter MVP

  11. Solution Model-View-Presenter Model-View-ViewModel (+Coordinator)

  12. MVVM UIViewController Model View Controller

  13. Model ViewModel View UIViewController MVVM

  14. Model ViewModel View UIViewController UIView MVVM Navigation?

  15. MVVM stack Model ViewModel View Coordinator MVVM-C

  16. MVVM stack Coordinator MVVM stack MVVM stack MVVM-C

  17. MVVM stack MVVM stack MVVM stack MVVM stack Coordinator Coordinator

    MVVM-C
  18. View Model (Interactor) Activity Layout Presenter MVVM vs MVP Model

    ViewModel View UIViewController UIView
  19. • Provides data to Presenter/ViewModel • Processes data (networking, persistence)

    Model (Interactor) Responsibilities
  20. Responsibilities • Draws UI with provided data • Notifies Presenter/ViewModel

    about user actions View
  21. • Handles user actions from View • Gets data from

    Model • Updates data in Model • Business logic • Provides updated/processed data to View Presenter/ViewModel Responsibilities ——————————————————— • Communicates with Coordinator
  22. • Handle navigation • Build the MVVM stacks Coordinator Responsibilities

  23. Same thing, different names?

  24. Bindings View ViewModel Owns Observes by Reactive approach

  25. Simulate bindings View ViewModel Owns Notifies To be continued… …with

    Reactive approach?
  26. Business logic is decoupled from UI Easy to maintain Easy

    to test Easy to reuse components MVP/MVVM-C advantages
  27. Thank you! Questions