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

MVVM-C In Practice

MVVM-C In Practice

Model View View Model has been around as an architecture pattern for quite a while now and is generally accepted as an improvement over plain MVC. However MVVM still does not solve the problem of who takes responsibility for navigation hence the C, Coordinators. The session will look at developing an MVVM-C based app with Swift and Protocols using a mix of example along with hints and tips all gained from using MVVM-C in a recent OS X and iOS application where much of the code was shared.

89f2359eb111913561bc5531c6c5ccd7?s=128

macdevnet

May 23, 2016
Tweet

Transcript

  1. MVVM-C In Practice Steve Scott (Scotty) @macdevnet

  2. Listen Carefully!

  3. • Code Sharing Between iOS and OSX apps • Good

    Test Coverage • Easy To Test • Flexible Goals
  4. Model Controller View

  5. Model ? Controller UIViewController View UIView

  6. Model ? View Model ? View UIView Controller UIViewController

  7. Model ? View Model ? View UIView Controller UIViewController Presentation

    User Input Business Logic Data C.R.U.D
  8. Model ? View Model ? View UIView Controller UIViewController Business

    Logic Data C.R.U.D Coordinator Navigation / Flow Presentation User Input
  9. None
  10. None
  11. None
  12. None
  13. Protocols

  14. View UIView Controller UIViewController Views

  15. View UIView Controller UIViewController View Model Views

  16. None
  17. None
  18. None
  19. View UIView Controller UIViewController View Model Views Immutable?

  20. View UIView Controller UIViewController View Model Protocol Views Property Delegate

  21. None
  22. None
  23. View Model View Models

  24. • Get Data From a Model • Send Data To

    a Model • Provide a Data Interface For Views • Inform View of Data Changes • Business Logic • Communicate State to Coordinator View Model View Models
  25. None
  26. None
  27. None
  28. Model Models

  29. • Handle Data Access • Handle Saving Data • Uses

    functions not properties • All functions return data in a completion handler • Always assume to be asynchronous Model Models
  30. None
  31. None
  32. None
  33. None
  34. None
  35. None
  36. None
  37. Coordinator Coordinators

  38. • Handle App Navigation • Build the MVVM Stacks Coordinators

    Coordinators
  39. None
  40. None
  41. None
  42. None
  43. None
  44. None
  45. None
  46. None
  47. None
  48. None
  49. None
  50. None
  51. Model ? View Model ? View UIView Controller UIViewController Business

    Logic Data C.R.U.D Coordinator Navigation / Flow Presentation User Input
  52. Github: macdevnet/mvvmc-demo

  53. Twitter: @macdevnet