Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

Hi, I'm Mateusz! Mobile Tech Lead @Codete @cojoj 2

Slide 3

Slide 3 text

“There are two ways of getting home...” https://www.wordonfire.org/wof-site/media/brchesterton2.jpg 3

Slide 4

Slide 4 text

“...and one of them is to stay there.” https://www.wordonfire.org/wof-site/media/brchesterton2.jpg 4

Slide 5

Slide 5 text

“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

Slide 6

Slide 6 text

Agenda » Historical Overview » Pros & Cons » Problems & Misbeliefs » Competitors » My Personal Approach (Optional) » Summary 6

Slide 7

Slide 7 text

History https://www.nationalgeographic.com/content/dam/archaeologyandhistory/rights-exempt/history-magazine/ 2016/07-08/05-abu-simbel.jpg 7

Slide 8

Slide 8 text

Xerox PARC California 1970s http://www.siliconvalleyguide.info/wp-content/uploads/2015/03/PARC-2.jpg 8

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

2nd most loved language of 2017!!! (Swift's 4th, yay!) 10

Slide 11

Slide 11 text

Graphical User Interface http://images.computerhistory.org/revonline/images/500004472-03-01.jpg?w=600 11

Slide 12

Slide 12 text

Xerox Alto Smalltalk + GUI https://www.parc.com/content/news/media-library/altochildren9.5x7.5.jpg 12

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

Whatcha talkin bout, Willis? 14

Slide 15

Slide 15 text

Xerox PARC Learning Research Group http://worrydream.com/EarlyHistoryOfSmalltalk/Images/kiddikomp.png 15

Slide 16

Slide 16 text

Model-View-Controller Trygve Reenskaug 1978 - 1979 http://static.cw.newsfront.no/files/styles/cropimagemain_large/public/dcx/reenskaug-trygve-1.jpg 16

Slide 17

Slide 17 text

Original ideal MVC 17

Slide 18

Slide 18 text

Model “Models represent knowledge. A model could be a single object (rather uninteresting), or it could be some structure of objects.” T. Reenskaug 18

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

Couldn't get any simpler... 21

Slide 22

Slide 22 text

22

Slide 23

Slide 23 text

23

Slide 24

Slide 24 text

Pros & Cons http://www.pxleyes.com/images/contests/measuring-instruments/fullsize/Old-Scale-50a8e2e07b1a5_hires.jpg 24

Slide 25

Slide 25 text

Pros » Simultaneous development » High cohesion » Low coupling » Ease of modification » Multiple views for a model 25

Slide 26

Slide 26 text

Cons » Code navigability » Multi-artifact consistency » Pronounced learning curve 26

Slide 27

Slide 27 text

MVC is not a silver bullet! 27

Slide 28

Slide 28 text

Where's Apple in this whole story? 28

Slide 29

Slide 29 text

But, there's one more thing... 29

Slide 30

Slide 30 text

30

Slide 31

Slide 31 text

» Objective-C (incorporated) » Cocoa » Cocoa MVC » NeXT's WebObjects » NeXTSTEP » Mac OS X 31

Slide 32

Slide 32 text

Cocoa MVC 32

Slide 33

Slide 33 text

MVP: Model- View-Presenter The Taligent Programming Model for C++ and Java 33

Slide 34

Slide 34 text

MVP == Cocoa MVC Presenter == Supervising Controller 34

Slide 35

Slide 35 text

Pros & Cons http://www.pxleyes.com/images/contests/measuring-instruments/fullsize/Old-Scale-50a8e2e07b1a5_hires.jpg 35

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

Cons » Effort » Presenter can easily become god class » There are multiple axes of the application 37

Slide 38

Slide 38 text

“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

Slide 39

Slide 39 text

Problems & Misbeliefs http://www.kubipet.com/data/out/19/iwp779816317-blackboard-wallpapers.jpg 39

Slide 40

Slide 40 text

#1. “Mobile apps are now more complicated than they used to be, and MVC is too simple to handle their scale.” 40

Slide 41

Slide 41 text

#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

Slide 42

Slide 42 text

#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

Slide 43

Slide 43 text

#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

Slide 44

Slide 44 text

Competitors https://www.ultimaterb.com/wp-content/uploads/2015/03/iStock_000015985266XXLarge-web.jpg 44

Slide 45

Slide 45 text

Groups » Kinda supersets of MVC » Reactive » Unidirectional Dataflow » We can do it differently 45

Slide 46

Slide 46 text

Kinda supersets of MVC » Model-View-Presenter » Model-View-ViewModel » VIPER 46

Slide 47

Slide 47 text

VIPER VIPER VIPER 47

Slide 48

Slide 48 text

“Do you strictly follow VIPER architecture?” 48

Slide 49

Slide 49 text

https://www.reddit.com/r/iOSProgramming/comments/5pcebg/viperhowstrictlydoyouguysfollowthisor/ 49

Slide 50

Slide 50 text

“No. VIPER is what happens when former enterprise Java programmers invade the iOS world.” 50

Slide 51

Slide 51 text

https://www.reddit.com/r/iOSProgramming/comments/5pcebg/viperhowstrictlydoyouguysfollowthisor/dcqa1uj/ 51

Slide 52

Slide 52 text

Reactive » RxSwift/RxCocoa » ReactiveSwift/ReactiveCocoa » Cocoa Bindings 52

Slide 53

Slide 53 text

“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

Slide 54

Slide 54 text

54

Slide 55

Slide 55 text

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

Slide 56

Slide 56 text

Unidirectional dataflow » ReSwift » ReduxSwift » Katana » VueFlux 56

Slide 57

Slide 57 text

Redux-like architecture 57

Slide 58

Slide 58 text

We can do it differently » Elm Architecture » React Native 58

Slide 59

Slide 59 text

Elm-like architecture 59

Slide 60

Slide 60 text

Ain't nobody got time for that! 60

Slide 61

Slide 61 text

My Personal Approach http://www.bestphotosite.net/photos/23193280813765.jpg 61

Slide 62

Slide 62 text

I'm ! for Cocoa MVC... 62

Slide 63

Slide 63 text

But, I also like the idea of ViewModels... (Mostly because I use RxSwift) 63

Slide 64

Slide 64 text

So, let's call it... MVC-ish! 64

Slide 65

Slide 65 text

“I’m also guilty of using the term MVVM, but actually writing MVC code. I don’t mind it, though.” @thesunshinejr 65

Slide 66

Slide 66 text

Łukasz Is Guilty, Too! 66

Slide 67

Slide 67 text

Great minds think alike! ! (But I want my promised beer anyway) 67

Slide 68

Slide 68 text

68

Slide 69

Slide 69 text

But how do you navigate? 69

Slide 70

Slide 70 text

70

Slide 71

Slide 71 text

Wait, what? 71

Slide 72

Slide 72 text

Back to the navigation... 72

Slide 73

Slide 73 text

73

Slide 74

Slide 74 text

Coordinators, Flow controllers 74

Slide 75

Slide 75 text

75

Slide 76

Slide 76 text

What the heck with Reactive? 76

Slide 77

Slide 77 text

Informing others » KVO » Notification Center » Delegates » Target-Action » Closures » ? 77

Slide 78

Slide 78 text

Observable 78

Slide 79

Slide 79 text

“Reactive MVVM/MVC with Coordinators and Routing” 79

Slide 80

Slide 80 text

80

Slide 81

Slide 81 text

Summary http://i0.wp.com/bossfight.co/wp-content/uploads/2015/03/boss-fight-stock-images-photos-free-photography-pencil- paper.jpg 81

Slide 82

Slide 82 text

MVC introduces complexity. Though, it's supersets double and triple it. 82

Slide 83

Slide 83 text

Be flexible, you don't have to use one architecture! 83

Slide 84

Slide 84 text

Naming Naming Naming x100 84

Slide 85

Slide 85 text

Stick to Apple technologies 85

Slide 86

Slide 86 text

Think! 86

Slide 87

Slide 87 text

Before you blame something MVC, think about it even deeper. 87

Slide 88

Slide 88 text

Improvise. Adapt. Overcome 88

Slide 89

Slide 89 text

89

Slide 90

Slide 90 text

90

Slide 91

Slide 91 text

Questions? 91