$30 off During Our Annual Pro Sale. View Details »

I'm only MVC after all. Don't put your blame on...

I'm only MVC after all. Don't put your blame on me.

"There are two ways of getting home; and one of them is to stay there.
The other is to walk round the whole world till we come back to the same
place"
~ G. K. Chesterton, The Everlasting Man

In 10 years of iOS presence on the market we've seen many changes in the SDK.
But Cocoa MVC... Feels untouched, even forgotten!
Maybe it's perfect...
Maybe it's rotted...
Who knows?
We can see that silence around this topic has driven many developers mad, so they've started inventing new architectures, and boasting about each one being better than the other, and of course being better than MVC.
I'd like to flip the coin and show you that MVC isn't the problem.

Mateusz Zając

December 07, 2017
Tweet

More Decks by Mateusz Zając

Other Decks in Programming

Transcript

  1. “The other is to walk round the whole world till

    we come back to the same place.” G. K. Chesterton, The Everlasting Man https://www.wordonfire.org/wof-site/media/brchesterton2.jpg 5
  2. Agenda » Historical Overview » Pros & Cons » Problems

    & Misbeliefs » Competitors » My Personal Approach (Optional) » Summary 6
  3. Smalltalk 1972 » Object-Oriented » Class-based Inheritance » Dynamically Typed

    » Reflective » Message Driven https://cdn-images-1.medium.com/max/597/1*9qr-I3aJLr0IrM256gVIvg.jpeg 9
  4. DynaBook 1972 “A portable computer that should contain all data

    of interest to its owner/user. (...) The owner/user should be able to understand and write the programs.” https://blog.codinghorror.com/content/images/uploads/2008/11/6a0120a85dcdae970b0128777053a5970c-pi.png 13
  5. Model “Models represent knowledge. A model could be a single

    object (rather uninteresting), or it could be some structure of objects.” T. Reenskaug 18
  6. View “A view is a (visual) representation of its model.

    It would ordinarily highlight certain attributes of the model and suppress others.” T. Reenskaug 19
  7. Controller “A controller is a link between a user and

    the system. It provides the user with input by arranging for relevant views to present themselves in appropriate places on the screen.” T. Reenskaug 20
  8. 22

  9. 23

  10. Pros » Simultaneous development » High cohesion » Low coupling

    » Ease of modification » Multiple views for a model 25
  11. 30

  12. Pros » Logic can be moved from the view to

    the presenter/ supervising controller » It's easier to unit test UI, because of the presenter » UI and app logic can be developed independently » It breaks MVC's circularity! 36
  13. Cons » Effort » Presenter can easily become god class

    » There are multiple axes of the application 37
  14. “If we take NeXTStep 4 as the origin date for

    Cocoa’s current Model- View-Controller pattern then it is 20 years old this year” Matt Gallagher https://www.cocoawithlove.com/blog/mvc-and-cocoa.html 38
  15. #1. “Mobile apps are now more complicated than they used

    to be, and MVC is too simple to handle their scale.” 40
  16. #2. “Cocoa MVC is poorly documented and lacks proper learning

    materials. It feels like Apple actually doesn't care about it anymore (but, have they ever?).” 41
  17. #3. “It's so easy to write an app right now,

    that carrying about such nuances as app architecture is a waste of time.” #4. “There are so many developers lacking the basic CS education, and they simply don't get why app architecture is important.” 42
  18. #5. “Architectures on other platforms are so well written and

    well thought, that we should also have something like this instead of this dead-simple Cocoa MVC.” 43
  19. Groups » Kinda supersets of MVC » Reactive » Unidirectional

    Dataflow » We can do it differently 45
  20. “Bindings technology provides a means of keeping model and view

    values synchronized without you having to write a lot of glue code” https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/ WhatAreBindings.html 53
  21. 54

  22. Reactive in code // RxSwift with RxCocoa (I skipped disposing)

    viewModel.title.drive(skillTitleLabel.rx.text) // ReactiveCocoa with ReactiveSwift nameLabel.reactive.text <~ person.name // Hanson bind(viewModel.isLoadingData, to: view.showsActivityIndicator) // Bond textField.reactive.text.bind(to: label) 55
  23. “I’m also guilty of using the term MVVM, but actually

    writing MVC code. I don’t mind it, though.” @thesunshinejr 65
  24. 68

  25. 70

  26. 73

  27. 75

  28. 80

  29. 89

  30. 90