Choosing the architecture
-
Upload
lucas-fonseca -
Category
Software
-
view
195 -
download
0
Transcript of Choosing the architecture
![Page 1: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/1.jpg)
CHOOSING THE ARCHITECTUREFROM MV(X) TO VIP(ER)
1
![Page 2: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/2.jpg)
ABOUT US
Giovane Berny PossebonMobile Developer
Lucas Dutra FonsecaMobile Developer
![Page 3: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/3.jpg)
WHY CARE ABOUT IT?
3
![Page 4: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/4.jpg)
"BECAUSE IF YOU DON’T, ONE DAY, DEBUGGING A HUGE CLASS WITH DOZENS DIFFERENT THINGS, YOU’LL FIND YOURSELF BEING UNABLE TO FIND AND FIX ANY BUGS IN YOUR CLASS."
Someone who’s right
WHY CARE ABOUT IT? 4
![Page 5: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/5.jpg)
WHY CARE ABOUT IT?
REASONS
▸ This class is the UIViewController subclass.
▸ Your data is stored directly in the UIViewController
▸ Your UIViews do almost nothing
▸ The Model is a dumb data structure
▸ Your Unit Tests cover nothing
5
![Page 6: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/6.jpg)
WHY CARE ABOUT IT?
SO WHAT A GOOD ARCHITECTURE SHOULD HAVE?
▸ Balanced distribution of responsibilities among entities with strict roles.
▸ Testability usually comes from the first feature.
▸ Ease of use and a low maintenance cost.
6
![Page 7: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/7.jpg)
THEN SHOW ME THESE ARCHITECTURES!
7
![Page 8: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/8.jpg)
THEN SHOW ME THESE ARCHITECTURES!
RENOWNED ARCHITECTURES
▸ MVC
▸ MVP
▸ MVVM
▸ VIPER
▸ VIP
8
![Page 9: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/9.jpg)
MVC MODEL-VIEW-CONTROLLER
9
![Page 10: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/10.jpg)
MVC - MODEL-VIEW-CONTROLLER
HOW IT SHOULD BE
VIEW
CONTROLLER
MODELUpdates
NotifiesSend actions
10
![Page 11: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/11.jpg)
MVC - MODEL-VIEW-CONTROLLER
HOW IT REALLY IS
VIEW CONTROLLER MODELOwns and updates
Notifies
11
![Page 12: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/12.jpg)
MVC - MODEL-VIEW-CONTROLLER
HOW IT REALLY IS
VIEW CONTROLLER MODELOwns and updates
Notifies
MVC
12
![Page 13: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/13.jpg)
MVC - MODEL-VIEW-CONTROLLER
HOW IT REALLY IS
VIEW CONTROLLER MODELOwns and updates
Notifies
Massive View Controller
13
![Page 14: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/14.jpg)
MVC - MODEL-VIEW-CONTROLLER
CONCLUSION
▸ Distribution of Responsibilities - View and controller tightly coupled
▸ Testability - Only model is testable
▸ Ease of Use - Low amount of code. Everyone is familiar with it.
14
![Page 15: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/15.jpg)
MVP MODEL-VIEW-PRESENTER
15
![Page 16: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/16.jpg)
What if I told you, the UIViewController is the View.
![Page 17: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/17.jpg)
MVP - MODEL-VIEW-PRESENTER
MVC IN THE RIGHT WAY
PASSIVE VIEW
PRESENTER
MODELUpdates
Owns and updatesOwns and send actions
Notifies
17
![Page 18: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/18.jpg)
MVP - MODEL-VIEW-PRESENTER
MVC IN THE RIGHT WAY
PASSIVE VIEW
PRESENTER
MODELUpdates
Owns and updatesOwns and send actions
Notifies
UIViewController
UIKit independent mediator
18
![Page 19: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/19.jpg)
MVP - MODEL-VIEW-PRESENTER
CONCLUSION
▸ Distribution of Responsibilities - Most of responsibilities divided between the Presenter and the Model, with the pretty dumb View
▸ Testability - Good, we can test most of the business logic due to the dumb View
▸ Ease of Use - Substantial amount of code, although idea is very clear
19
![Page 20: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/20.jpg)
MVVM MODEL-VIEW-VIEWMODEL
20
![Page 21: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/21.jpg)
MVVM - MODEL-VIEW-VIEWMODEL
THE GREATEST OF THE MV(X) KIND
VIEW
VIEWMODEL
MODELUpdates
Owns and updatesOwns and send actions
Notifies
21
![Page 22: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/22.jpg)
MVVM - MODEL-VIEW-VIEWMODEL
CONCLUSION
▸ Distribution of Responsibilities - Similar to MVP, but View has more responsibilities than the MVP’s
▸ Testability - View Model knows nothing about the View, this allows us to test it easily. The View might be also tested
▸ Ease of Use - It has almost the same amount of code as the MVP
22
![Page 23: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/23.jpg)
VIPER
23
![Page 24: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/24.jpg)
VIPER
THE LEGO ARCHITECTURE
VIEW
PRESENTER
ENTITY
Updates
Owns and asks for updatesOwns and send actions
Notifies INTERACTOR
ROUTER
Knows about
24
![Page 25: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/25.jpg)
VIPER
THE LEGO ARCHITECTURE
VIEW
PRESENTER
ENTITY
Updates
Owns and asks for updatesOwns and send actions
Notifies INTERACTOR
ROUTER
Knows about
Manipulates data anduse cases
UIKit independent mediator
Former Model
25
![Page 26: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/26.jpg)
VIPER
CONCLUSION
▸ Distribution of Responsibilities - VIPER is a champion in distribution of responsibilities.
▸ Testability - better distribution — better testability
▸ Ease of Use - You have to write huge amount of interface for classes with very small responsibilities.
26
![Page 27: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/27.jpg)
VIP CLEAN SWIFT
27
![Page 28: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/28.jpg)
VIP
THE CLEAN ARCHITECTURE
VIEW PRESENTER
ENTITY
Updates
Process and deliver dataSend actions INTERACTOR
ROUTER
Knows about
Owns
28
![Page 29: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/29.jpg)
VIP
THE CLEAN ARCHITECTURE
VIEW PRESENTER
ENTITY
Updates
Process and deliver dataSend actions INTERACTOR
ROUTER
Knows about
Owns
UIKit independent mediator Former Model
29
![Page 30: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/30.jpg)
VIP
CONCLUSION
▸ Distribution of Responsibilities - VIP is as good as VIPER in terms of distribution of responsibilities.
▸ Testability - Also comparable to VIPER
▸ Ease of Use - Great amount of classes with very small responsibilities, but clearer than VIPER
30
![Page 31: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/31.jpg)
CHOOSING THE ARCHITECTURE
REFERENCES
▸ https://medium.com/ios-os-x-development/ios-architecture-patterns-ecba4c38de52
▸ http://clean-swift.com/clean-swift-ios-architecture/
31
![Page 32: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/32.jpg)
CHOOSING THE ARCHITECTURE
CODE REPOSITORY
▸ https://github.com/lfonseca/choosing-the-architecture
32
![Page 33: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/33.jpg)
THANKS!
Giovane Berny PossebonMobile Developer
Lucas Dutra FonsecaMobile Developer
![Page 34: Choosing the architecture](https://reader031.fdocuments.in/reader031/viewer/2022030302/587df2961a28abab7e8b515b/html5/thumbnails/34.jpg)
EXPERIENCES SO FAR…
34