SlideShare a Scribd company logo
8
Most read
13
Most read
14
Most read
iOS Architecture
Essential
Jiakai(Jacky) Lian
Mobile Developer @ GoGet
About Me
❖ Focus on mobile development since
the era of 2G
❖ Master of Applied IT @ Monash
❖ Not a full stack developer
❖ Focus on iOS in recent 2 years
❖ Recently Joined GoGet CarSharing
❖ LinkedIn:
https://au.linkedin.com/in/jacky-lian-
06493379
❖ GitHub: https://github.com/jiakai-
lian/
Purpose of Architecture
Design
❖ Resolve real business problems
❖ Remove unnecessary dependencies
❖ Reduce maintenance cost
❖ Prepare for changes
3 Main Roles in Architecture
❖ Data Owner
❖ Data Processor
❖ Data Consumer
Everything starts from MVC
❖ MVC: Model+View+Controller
❖ MVC in Web programming
❖ View Container: Web Browser
❖ Model: Model Layer
What Apple promised
The Reality
❖ MVC = Massive View Controller
❖ View Controllers have too many responsibilities: Networking, Data Access,UI
configuration, Data Source, Delegate …
❖ Shared Data causes problems (Mutability Management)
❖ Controllers are the least reusable classes in the project
❖ “Cocoa MVC is the best architectural pattern in terms of the speed of the
development.”
Slim Model V.S. Fat Model
❖ Fat Model
❖ Business Logic in Model
❖ Slim Model
❖ Model + Helpers
❖ MVC-S: MVC+Data Store(Data Access)
❖ MVC-N: MVC+Networking
The True MVC in Mobile:
MVP
❖ MVP: Model+Passive View+Presenter
❖ All UI logic in presenter.
❖ View knows nothing about Model
MVVM
❖ MVVM = Model+View+ViewModel
❖ ViewModel Definition
MVVM:View Model
❖ Non-Pattern ViewModel: ViewData/Transition Data (Immutable)
❖ ViewModel in MVVM: Independent Presentation Logic
MVVM: Where is the
Controller
❖ MVVM = M-VM-C-V = Model ViewModel Controller View
❖ Controller bind View and ViewModel together
Benefits of ViewModel
❖ No direct dependency between Model & View
❖ UI Independent Presentation Logic
MVVM With Binding
❖ Fine without binding
❖ Even better with binding
❖ Popular Binding Frameworks: ReactiveCocoa(ObjC &
Swift), RxSwift
❖ Reactive : Learning Cost ⬆
❖ Binding: Debugging Difficulty⬆
VIPER
❖ VIPER = View+Interactor+Presenter+Entity+Router
❖ Interactor: Business Logic, using external data access layer
❖ Presenter: UI related (but UIKit independent) business logic
❖ Entities: Slim Model (Plain Data Objects)
❖ Router: Routing between different modules
VIPER: Highlights
❖ Evenly distribute responsibilities
❖ UseCase focused
❖ Able to combine different UI protocols to build up a screen
VIPER: Problems
❖ Too many classes: Development/Maintenance Cost ⬆
❖ Too complex for simple apps: Slow down the development
VIPER: Suggestions
❖ Workload Reduce: Use Script/Template to generate all those
classes
❖ Not a practical choice for s/m projects
❖ A option for large projects (Team Size ≈ 5/Development Life Cycle ≥
6 month)
Ziggurat
❖ Created by Square
❖ Inspired by React Native & Flux
Ziggurat
❖ More layers distribute
responsibility evenly
❖ The service layer
encapsulates mutability
❖ Presenter & Renders are
stateless
❖ One Way Data Flow
❖ Repository = Data Store
❖ View Model = View Data
❖ Drawback: Relatively hard to
manage animations
Rules Of Thumb
❖ Dependency is the No.1 concern
❖ More layers = Less coupling = Harder to understand
❖ No right or wrong architecture
❖ Plan well then improve your architecture iteratively
Massive Class Prevention
❖ No more than
300 lines of code
Future Topics
❖ Architecture Design By Practice
❖ Protocol Oriented Design in Swift
❖ iOS Animation Design By A Live Example/Examples
References
❖ http://casatwy.com/iosying-yong-jia-gou-tan-viewceng-de-zu-zhi-he-diao-yong-fang-
an.html
❖ https://www.objc.io/issues/13-architecture/viper/
❖ https://www.objc.io/issues/13-architecture/mvvm/
❖ https://medium.com/ios-os-x-development/ios-architecture-patterns-
ecba4c38de52#.tlnbspmx8
❖ https://www.raywenderlich.com/62699/reactivecocoa-tutorial-pt1
❖ https://www.youtube.com/watch?v=4cP1p5VOrSI
❖ https://corner.squareup.com/2015/12/ziggurat-ios-app-architecture.html
❖ http://khanlou.com/2015/12/mvvm-is-not-very-good/
❖ http://limboy.me/ios/2015/09/27/ios-mvvm-without-reactivecocoa.html

More Related Content

PPTX
Introduction to Spring Boot
PPTX
Introduction to Spring Framework
PPTX
Layer architecture of ios (1)
PPTX
iOS Architecture
PPTX
PPT on iOS
PPTX
Java Spring Framework
PPT
PPTX
What is component in reactjs
Introduction to Spring Boot
Introduction to Spring Framework
Layer architecture of ios (1)
iOS Architecture
PPT on iOS
Java Spring Framework
What is component in reactjs

What's hot (20)

PPTX
Spring Boot
PPTX
Apple iOS
PPTX
Spring boot
PPSX
Spring - Part 1 - IoC, Di and Beans
PPTX
Spring Framework
PPTX
Spring boot
PDF
Swift Tutorial For Beginners | Swift Programming Tutorial | IOS App Developme...
DOCX
Spring notes
PDF
Spring MVC Framework
PPTX
Day: 1 Introduction to Mobile Application Development (in Android)
PDF
A Basic Django Introduction
PPT
Php File Operations
PPTX
Java script
PPTX
Introduction to Android ppt
PPT
Servlet life cycle
PPTX
Php.ppt
PPT
Java Server Faces (JSF) - Basics
PDF
iOS Application Security
PPTX
Express js
PPT
Angular Introduction By Surekha Gadkari
Spring Boot
Apple iOS
Spring boot
Spring - Part 1 - IoC, Di and Beans
Spring Framework
Spring boot
Swift Tutorial For Beginners | Swift Programming Tutorial | IOS App Developme...
Spring notes
Spring MVC Framework
Day: 1 Introduction to Mobile Application Development (in Android)
A Basic Django Introduction
Php File Operations
Java script
Introduction to Android ppt
Servlet life cycle
Php.ppt
Java Server Faces (JSF) - Basics
iOS Application Security
Express js
Angular Introduction By Surekha Gadkari
Ad

Similar to iOS Architecture (20)

PPTX
001. Introduction about React
PPTX
Stacker's the way you connect the world .pptx
PPTX
Html5 data viz
PDF
From Monoliths to Services: Paying Your Technical Debt
PDF
Introduction to Web Frameworks
PDF
2022-Devnexus-StatefulMicroservices.pptx.pdf
DOC
SadikulIslamDotNetResume
PDF
AngularJS in Production (CTO Forum)
DOC
B.Karthik
PPTX
Dirigible powered by Orion for Cloud Development (EclipseCon EU 2015)
PPTX
React.js at Cortex
PDF
DevOpsDays Warsaw 2015: Automating microservices in Syncano – Michał Kobus & ...
PPTX
[Mas 500] Web Basics
PDF
Top JavaScript Frameworks for Mobile App Development
PDF
Front end microservices: architectures and solution
PPTX
Shillum "Building for the Future: Interoperability"
PDF
The MEAN stack - SoCalCodeCamp - june 29th 2014
PPTX
DOES SFO 2016 - Greg Maxey and Laurent Rochette - DSL at Scale
PDF
Java Microservices HJUG
PDF
Architecting Cloud Native Applications
001. Introduction about React
Stacker's the way you connect the world .pptx
Html5 data viz
From Monoliths to Services: Paying Your Technical Debt
Introduction to Web Frameworks
2022-Devnexus-StatefulMicroservices.pptx.pdf
SadikulIslamDotNetResume
AngularJS in Production (CTO Forum)
B.Karthik
Dirigible powered by Orion for Cloud Development (EclipseCon EU 2015)
React.js at Cortex
DevOpsDays Warsaw 2015: Automating microservices in Syncano – Michał Kobus & ...
[Mas 500] Web Basics
Top JavaScript Frameworks for Mobile App Development
Front end microservices: architectures and solution
Shillum "Building for the Future: Interoperability"
The MEAN stack - SoCalCodeCamp - june 29th 2014
DOES SFO 2016 - Greg Maxey and Laurent Rochette - DSL at Scale
Java Microservices HJUG
Architecting Cloud Native Applications
Ad

iOS Architecture

  • 2. About Me ❖ Focus on mobile development since the era of 2G ❖ Master of Applied IT @ Monash ❖ Not a full stack developer ❖ Focus on iOS in recent 2 years ❖ Recently Joined GoGet CarSharing ❖ LinkedIn: https://au.linkedin.com/in/jacky-lian- 06493379 ❖ GitHub: https://github.com/jiakai- lian/
  • 3. Purpose of Architecture Design ❖ Resolve real business problems ❖ Remove unnecessary dependencies ❖ Reduce maintenance cost ❖ Prepare for changes
  • 4. 3 Main Roles in Architecture ❖ Data Owner ❖ Data Processor ❖ Data Consumer
  • 5. Everything starts from MVC ❖ MVC: Model+View+Controller ❖ MVC in Web programming ❖ View Container: Web Browser ❖ Model: Model Layer
  • 7. The Reality ❖ MVC = Massive View Controller ❖ View Controllers have too many responsibilities: Networking, Data Access,UI configuration, Data Source, Delegate … ❖ Shared Data causes problems (Mutability Management) ❖ Controllers are the least reusable classes in the project ❖ “Cocoa MVC is the best architectural pattern in terms of the speed of the development.”
  • 8. Slim Model V.S. Fat Model ❖ Fat Model ❖ Business Logic in Model ❖ Slim Model ❖ Model + Helpers ❖ MVC-S: MVC+Data Store(Data Access) ❖ MVC-N: MVC+Networking
  • 9. The True MVC in Mobile: MVP ❖ MVP: Model+Passive View+Presenter ❖ All UI logic in presenter. ❖ View knows nothing about Model
  • 10. MVVM ❖ MVVM = Model+View+ViewModel ❖ ViewModel Definition
  • 11. MVVM:View Model ❖ Non-Pattern ViewModel: ViewData/Transition Data (Immutable) ❖ ViewModel in MVVM: Independent Presentation Logic
  • 12. MVVM: Where is the Controller ❖ MVVM = M-VM-C-V = Model ViewModel Controller View ❖ Controller bind View and ViewModel together
  • 13. Benefits of ViewModel ❖ No direct dependency between Model & View ❖ UI Independent Presentation Logic
  • 14. MVVM With Binding ❖ Fine without binding ❖ Even better with binding ❖ Popular Binding Frameworks: ReactiveCocoa(ObjC & Swift), RxSwift ❖ Reactive : Learning Cost ⬆ ❖ Binding: Debugging Difficulty⬆
  • 15. VIPER ❖ VIPER = View+Interactor+Presenter+Entity+Router ❖ Interactor: Business Logic, using external data access layer ❖ Presenter: UI related (but UIKit independent) business logic ❖ Entities: Slim Model (Plain Data Objects) ❖ Router: Routing between different modules
  • 16. VIPER: Highlights ❖ Evenly distribute responsibilities ❖ UseCase focused ❖ Able to combine different UI protocols to build up a screen
  • 17. VIPER: Problems ❖ Too many classes: Development/Maintenance Cost ⬆ ❖ Too complex for simple apps: Slow down the development
  • 18. VIPER: Suggestions ❖ Workload Reduce: Use Script/Template to generate all those classes ❖ Not a practical choice for s/m projects ❖ A option for large projects (Team Size ≈ 5/Development Life Cycle ≥ 6 month)
  • 19. Ziggurat ❖ Created by Square ❖ Inspired by React Native & Flux
  • 20. Ziggurat ❖ More layers distribute responsibility evenly ❖ The service layer encapsulates mutability ❖ Presenter & Renders are stateless ❖ One Way Data Flow ❖ Repository = Data Store ❖ View Model = View Data ❖ Drawback: Relatively hard to manage animations
  • 21. Rules Of Thumb ❖ Dependency is the No.1 concern ❖ More layers = Less coupling = Harder to understand ❖ No right or wrong architecture ❖ Plan well then improve your architecture iteratively
  • 22. Massive Class Prevention ❖ No more than 300 lines of code
  • 23. Future Topics ❖ Architecture Design By Practice ❖ Protocol Oriented Design in Swift ❖ iOS Animation Design By A Live Example/Examples
  • 24. References ❖ http://casatwy.com/iosying-yong-jia-gou-tan-viewceng-de-zu-zhi-he-diao-yong-fang- an.html ❖ https://www.objc.io/issues/13-architecture/viper/ ❖ https://www.objc.io/issues/13-architecture/mvvm/ ❖ https://medium.com/ios-os-x-development/ios-architecture-patterns- ecba4c38de52#.tlnbspmx8 ❖ https://www.raywenderlich.com/62699/reactivecocoa-tutorial-pt1 ❖ https://www.youtube.com/watch?v=4cP1p5VOrSI ❖ https://corner.squareup.com/2015/12/ziggurat-ios-app-architecture.html ❖ http://khanlou.com/2015/12/mvvm-is-not-very-good/ ❖ http://limboy.me/ios/2015/09/27/ios-mvvm-without-reactivecocoa.html

Editor's Notes

  • #4: Today’s topic is more about inner module architecture instead of High Level architecture
  • #7: Who is the “View Container” in Apple’s MVC?
  • #9: Model = Model Class Fat Slim: Both in Modal Layers
  • #10: Storyboard inits controllers: Make implementation harder Dependency Injection Presenter controls everything
  • #11: What is View Model?