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

[SwiftAveiro] - MVVM World Tour 2016 by Rui Peres

[SwiftAveiro] - MVVM World Tour 2016 by Rui Peres

In this talk Rui Peres (@peres) will discuss the Why and the How in MVVM. Finally why things brake independently of the Architecture chosen and what we can do differently to improve our apps

SwiftAveiro

March 20, 2016
Tweet

Other Decks in Education

Transcript

  1. !

  2. AGENDA 1. What is MVVM? ! 2. What do you

    get with MVVM (versus MVC)? ☺ 3. FAQ # 4. Conclusion ✨
  3. !"

  4. Declarative data- and command- binding are implicit in the MVVM

    pattern.1 1 https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel
  5. When implemented outside of the Microsoft stack the presence of

    a declarative databinding technology is a key enabler of the pattern.2 2 https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel
  6. MVVM without a FRP inspired framework is only a small

    improvement over MVC: it still suffers from the same problem. — Me, just now
  7. "I have been hearing a lot about MVVM with Views

    and ViewModels, but where's the UIViewController now? What's its role?" — Maria João Pires
  8. ▸ Part of the View layer ▸ No Business Logic

    ▸ No Model layer Logic ▸ Normally not reusable
  9. protocol CellViewModelRepresentable { var title: String { get } var

    description: String { get } func fetchImage(callback: UIImage -> Void) func fetchUpvotes(callback: Int -> Void) }
  10. didSet { titleLabel.text = viewModel.title descriptionLabel.text= viewModel.description viewModel.fetchImage {[weak self]

    image in self?.imageView.image = image } viewModel.fetchUpvotes {[weak self] upvotes in self?.upvotes.text = String(upvotes) } }
  11. "I have seen ViewModels with localized strings, sometimes with Colors,

    other times interacting with the Model layer. What's really the role of the ViewModel? Is it supose to do all this?" — Guilhermina Suggia
  12. (...) the view model is responsible for exposing (converting) the

    data objects from the model in such a way objects are easily managed and consumed. 3 3 https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel
  13. "All the examples I have seen, revolve around the ViewModel

    interactions with the Model layer, does the ViewModel have anything to say about UI flows?" — Carlos Paião
  14. "Does it make sense for one View to have more

    than one ViewModel? What about the opposite? One ViewModel serving more than one View?" — Luísa Todi
  15. !

  16. MVVM IS NOT A SILVER BULLET AND YOU SHOULDN'T BLINDLY

    FOLLOW THE CURRENT CARGO CULT AROUND IT