SlideShare a Scribd company logo
#Swift3Arch
Implementing Clean
Architecture
for iOS
Jorge D. Ortiz-Fuentes
@jdortiz
A Canonical Examples
production
#Swift3Arch
#Swift3CA
Agenda
★ Goals
★ Before Clean Architecture
★ Clean Architecture Concepts
★ Implementation rules
★ Example App: RealProgrammers
★ Implement 1st User Story
★ Connect the pieces
★ References
#Swift3CA
Full Version: 3d
★ MVX
• Learn
• Extract MVP
★ 1st User Story
• Use Case
• Presenter
• View
• Entity Gateway
• Initial connection
★ Connectors
• Memory
Management
• Reuse
★ 2nd user story: add
• Navigation: Modal
vs Push
• Command pattern
• Immutables
• Observation
★ 3rd user story: detail
• Identity
• Use case factories
• 2nd use case in
the same view
★ Other use cases: just
logic
★ Forward flow
synchronization
★ Dependency Injection
★ Asynchrony
• Async entity
gateway
• Other tasks
#Swift3CA
LIVE Online Training
★ 3 days (same
weekday 3
continuous weeks)
★ 10 people max
★ Live coding shared
via video
conference
★ Chat running all the
time
★ Complete repo with
many commits and
Tests> 95%
★ Additional exercises
★ Ask as much as you
want!
More info at:
http://canonicalexamples.com
Goals
#Swift3CA
Goals
★ Understand the concepts
★ Learn the sources
★ Implement the ideas of the Clean
Architecture in a real app
★ Grow from here
Looking for
volunteers
Warning:
Background Ahead!
Before Clean
Architecture
#Swift3CA
Before Clean Architecture
★ MVC
★ MVP
★ MVVM
– Martin Fowler
“Different people reading about MVC in different places take
different ideas from it and describe these as 'MVC'. If this doesn't
cause enough confusion you then get the effect of
misunderstandings of MVC that develop through a system of
Chinese whispers.”
#Swift3CA
Tricky question
★ If [Model] + [View] + [Controller /
Presenter / View Model] = [TheApp]
★ How can Controller != Presenter != View
Model?
★ Responsibilities matter!
★ Other components (patterns) might be
involved.
#Swift3CA
The goal
★ Separation of responsibilities into roles. Is
it? Not historically. Other motivations.
Solving problem d’jour.
★ Now why?
• Testability
• Reusability
• Extensibility
#Swift3CA
MVC: The early days
★ Separated presentation: Model <->
Presentation (= V+C)
★ Observer originated from MVC, but
observing full object (properties = scalars)
★ Variations: Passive model, i.e. model
cannot send updates (for example HTTP)
#Swift3CA
Apple’s MVC
Ctrlr
ModelView
#Swift3CA
MVC: Composite Pattern
★ Composite
★ Strategy
★ Observer
#Swift3CA
iOS MVC
★ View
• Only UIView subclasses
• Show information and handle
events to controller
• Fully reusable library of views.
Consistent L&F
★ Controller
• Views delegate+dataSources
control what’s displayed
• Receive the events and
converts them into calls to the
model
• Observe the model and update
what is displayed on the view
• Implement presentation logic
★ Model
• Implements domain knowledge
/ business logic. Provides data
and commands
• Can be observed
• No references to the UI
Flow synchronization vs Observer
synchronization
#Swift3CA
MVC: testability
★ The views are somebody else's (Apple’s) problem.
★ Model is easy to test.
★ Controller is huge & has dependencies on the
model and on the views => Complex to test.
★ Too many levels of abstraction, only a few
methods exposed.
★ Some stuff in view controller that it is usually not
tested.
MVP
#Swift3CA
MVP
Presenter ModelView
Events Operations
Changes Changes
MVVM
#Swift3CA
MVVM
View Model ModelView
Events & Info Operations
Changes Changes
Clean Architecture
Concepts
What is missing?
#Swift3CA
Clean Architecture
★ Uncle Bob’s (Robert C. Martin’s)
architecture
★ Based on Onion, in turn based in
hexagonal, DCI and some others
#Swift3CA
Clean Architecture: iOS
App
Delegate
View (VC) Presenter Interactor
Entity
Gateway
Connector
#Swift3CA
Persistance FW
View
Network
LocationFW
Presenter
Entity Gateway
Clean Architecture
Interactor
Entity
Implementation
Rules
#Swift3CA
Rules
★ We are going to develop one module at a
time
★ Follow the dependency rules
★ YAGNI
★ No early optimization applied
★ It is easy to add tests, but no TDD in 3h
OK??
Example App:
RealProgrammers
#Swift3CA
Features
★ Add potential candidates (Name and important skills)
★ Show list of candidates with relative interview date
★ Remove candidates from list
★ Edit the data of any candidate
★ Contact candidate by email
★ Sync between devices
★ Universal app
★ Eye candy
★ iOS/macOS/watchOS/tvOS?
★ Credits
#Swift3CA
MVP Features
★ Add potential candidates (Name and important skills)
★ Show list of candidates with relative interview date
★ Remove candidates from list
★ Edit the data of any candidate
★ Contact candidate by email
★ Sync between devices
★ Universal app
★ Eye candy
★ iOS/macOS/watchOS/tvOS?
★ Credits
Implementing the
1st User Story
I feel like I could
Take On the World!
#Swift3CA
First User Story
★ Show a list of data elements to the user.
#Swift3CA
Interactor
View (VC) Presenter
Show

Programm
Entity
Gateway
#Swift3CA
Interactor
★ Grab data from the entity gateway
★ Convert it to what is needed to be
presented
★ Pass the results to the presenter
★ Start by defining the protocols
#Swift3CA
Presenter
View (VC)
Programm
ers

Show

Programm
Entity
Gateway
#Swift3CA
Presenter
★ Direction: only from interactor to view
★ Configure the (dumb) view with the data
provided to it
★ Create the protocol for the view (Simplest
wins!)
#Swift3CA
View
Programm
ers
Programm
ers

Show

Programm
Entity
Gateway
#Swift3CA
View
★ Combination of Views + View Controller
★ Make it dumb (passive), but useful
★ Tell the presenter about the relevant
events
★ Keep them decoupled
#Swift3CA
Presenter
Programm
ers
Programm
ers

Show

Programm
Entity
Gateway
#Swift3CA
Back to the Presenter
★ Implement responses to the user events.
★ Use the interactor
★ Add presentation logic to the presenter
part
#Swift3CA
Presentation Logic
★ Date should be relative (“Today”, “1d ago”,
“2w ago”)
★ That means current date is a dependency
that we want to control for tests
★ Use default value for the current date
#Swift3CA
Entity Gateway
Programm
ers
Programm
ers

Show

Programm
Entity
Gateway
#Swift3CA
Entity Gateway
★ Basic
★ Defer the decision of the persistence
framework for later.
★ Implement the minimum functionality in a
basic object.
★ Implications of the repository pattern.
References
#Swift3CA
References
★ http://martinfowler.com/eaaDev/
uiArchs.html
★ https://blog.8thlight.com/uncle-bob/
2012/08/13/the-clean-architecture.html
★ https://cleancoders.com/episode/clean-
code-episode-7/show
Thank
you!
@jdortiz
#Swift3Arch

More Related Content

What's hot (20)

PDF
The Continuous PHP Pipeline
Michelangelo van Dam
 
PDF
Android Services Skill Sprint
Jim McKeeth
 
PDF
The Python in the Apple
zeroSteiner
 
PDF
NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...
Frank van der Linden
 
PDF
Engage 2020: Hello are you listening, There is stream for everything
Frank van der Linden
 
PDF
MVVM & RxSwift
Thai Son Dang
 
PDF
Easily extend your existing php app with an api
Michelangelo van Dam
 
PDF
ColdBox Hierarchical MVC - Transform Your Monolith
Ortus Solutions, Corp
 
PDF
WilmingtonJS - React Native Under the Hood
Justin Poliachik
 
PDF
Queick: A Simple Job Queue System for Python
Ryota Suenaga
 
PPTX
Advanced AngularJS Tips and Tricks
Jeremy Likness
 
PPTX
Angular from a Different Angle
Jeremy Likness
 
PDF
Continuous delivery with open source tools
Sebastian Helzle
 
PDF
Rethinking the debugger
Iulian Dragos
 
PDF
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
Sauce Labs
 
PPTX
Celery workshop
Eswar Vandanapu
 
PDF
Swagger code motion talk
Victor Trakhtenberg
 
PPTX
Automating JavaScript testing with Jasmine and Perl
nohuhu
 
PDF
Si fa presto a dire serverless
Alessio Coser
 
PDF
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Milan 2017 - D...
Demi Ben-Ari
 
The Continuous PHP Pipeline
Michelangelo van Dam
 
Android Services Skill Sprint
Jim McKeeth
 
The Python in the Apple
zeroSteiner
 
NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...
Frank van der Linden
 
Engage 2020: Hello are you listening, There is stream for everything
Frank van der Linden
 
MVVM & RxSwift
Thai Son Dang
 
Easily extend your existing php app with an api
Michelangelo van Dam
 
ColdBox Hierarchical MVC - Transform Your Monolith
Ortus Solutions, Corp
 
WilmingtonJS - React Native Under the Hood
Justin Poliachik
 
Queick: A Simple Job Queue System for Python
Ryota Suenaga
 
Advanced AngularJS Tips and Tricks
Jeremy Likness
 
Angular from a Different Angle
Jeremy Likness
 
Continuous delivery with open source tools
Sebastian Helzle
 
Rethinking the debugger
Iulian Dragos
 
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
Sauce Labs
 
Celery workshop
Eswar Vandanapu
 
Swagger code motion talk
Victor Trakhtenberg
 
Automating JavaScript testing with Jasmine and Perl
nohuhu
 
Si fa presto a dire serverless
Alessio Coser
 
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Milan 2017 - D...
Demi Ben-Ari
 

Viewers also liked (20)

PDF
iOS viper presentation
Rajat Datta
 
PDF
10 tips for a reusable architecture
Jorge Ortiz
 
PDF
Clean Architecture
NSCoder Mexico
 
PDF
Introduction to VIPER Architecture
Hendy Christianto
 
PDF
Writing Clean Code in Swift
Derek Lee
 
PDF
Swift testing ftw
Jorge Ortiz
 
PDF
Testing iOS10 Apps with Appium and its new XCUITest backend
Testplus GmbH
 
PDF
Unit testing in swift 2 - The before & after story
Jorge Ortiz
 
PDF
Testing in swift
hugo lu
 
PPTX
Protocol-Oriented Programming in Swift
GlobalLogic Ukraine
 
PPT
Generating test cases using UML Communication Diagram
Praveen Penumathsa
 
PPTX
Unit Testing in Swift
GlobalLogic Ukraine
 
PDF
7 Stages of Unit Testing in iOS
Jorge Ortiz
 
PDF
iOS Unit Testing Like a Boss
Salesforce Developers
 
PPTX
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Jinkyu Kim
 
PDF
Clean Architecture
Badoo
 
PDF
Introducing Clean Architecture
Roc Boronat
 
PPTX
Digital water marking
Shashwat Shriparv
 
PPT
Digital Watermarking
Agrani Rastogi
 
PPTX
Clean architecture
andbed
 
iOS viper presentation
Rajat Datta
 
10 tips for a reusable architecture
Jorge Ortiz
 
Clean Architecture
NSCoder Mexico
 
Introduction to VIPER Architecture
Hendy Christianto
 
Writing Clean Code in Swift
Derek Lee
 
Swift testing ftw
Jorge Ortiz
 
Testing iOS10 Apps with Appium and its new XCUITest backend
Testplus GmbH
 
Unit testing in swift 2 - The before & after story
Jorge Ortiz
 
Testing in swift
hugo lu
 
Protocol-Oriented Programming in Swift
GlobalLogic Ukraine
 
Generating test cases using UML Communication Diagram
Praveen Penumathsa
 
Unit Testing in Swift
GlobalLogic Ukraine
 
7 Stages of Unit Testing in iOS
Jorge Ortiz
 
iOS Unit Testing Like a Boss
Salesforce Developers
 
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Jinkyu Kim
 
Clean Architecture
Badoo
 
Introducing Clean Architecture
Roc Boronat
 
Digital water marking
Shashwat Shriparv
 
Digital Watermarking
Agrani Rastogi
 
Clean architecture
andbed
 
Ad

Similar to iOS advanced architecture workshop 3h edition (20)

PDF
Session 7 - Overview of the iOS7 app development architecture
Vu Tran Lam
 
PDF
Architecting Alive Apps
Jorge Ortiz
 
PDF
Ui design patterns
Jorge Ortiz
 
PPT
ios basics
Muthu Sabarinathan
 
PPSX
SOLID Principles and The Clean Architecture
Mohamed Galal
 
PDF
iOS architecture patterns
allanh0526
 
PDF
"iOS: MVVMC" - Aleksandr Nikolajev from Mooncascade
MobileMonday Estonia
 
PDF
Viper
Jacob Van Brunt
 
PDF
Алексей Демедецкий: How to: RAC, TDD, MVVM
Fwdays
 
PDF
Intro to iOS Application Architecture
Make School
 
PDF
Introduction of Xcode
Dhaval Kaneria
 
PPTX
Training on iOS app development - Samesh Swongamikha & Neetin Sharma
MobileNepal
 
PPTX
iOS Architecture
Jacky Lian
 
PPTX
Basic iOS Training with SWIFT - Part 1
Manoj Ellappan
 
PDF
iOS Development Introduction
Gonzalo Parra
 
PDF
Exploring MVVM-C
Aydar Mukhametzyanov
 
PDF
Beginning Real World iOS App Development
Andri Yadi
 
KEY
iOS Design Patterns
Andreas Blick
 
PDF
Lecture 1 slides
amarprabhu
 
PDF
Jorge D. Ortiz Fuentes "Hands on Implementation of Clean Architecture for And...
IT Event
 
Session 7 - Overview of the iOS7 app development architecture
Vu Tran Lam
 
Architecting Alive Apps
Jorge Ortiz
 
Ui design patterns
Jorge Ortiz
 
ios basics
Muthu Sabarinathan
 
SOLID Principles and The Clean Architecture
Mohamed Galal
 
iOS architecture patterns
allanh0526
 
"iOS: MVVMC" - Aleksandr Nikolajev from Mooncascade
MobileMonday Estonia
 
Алексей Демедецкий: How to: RAC, TDD, MVVM
Fwdays
 
Intro to iOS Application Architecture
Make School
 
Introduction of Xcode
Dhaval Kaneria
 
Training on iOS app development - Samesh Swongamikha & Neetin Sharma
MobileNepal
 
iOS Architecture
Jacky Lian
 
Basic iOS Training with SWIFT - Part 1
Manoj Ellappan
 
iOS Development Introduction
Gonzalo Parra
 
Exploring MVVM-C
Aydar Mukhametzyanov
 
Beginning Real World iOS App Development
Andri Yadi
 
iOS Design Patterns
Andreas Blick
 
Lecture 1 slides
amarprabhu
 
Jorge D. Ortiz Fuentes "Hands on Implementation of Clean Architecture for And...
IT Event
 
Ad

More from Jorge Ortiz (20)

PDF
Tell Me Quando - Implementing Feature Flags
Jorge Ortiz
 
PDF
Unit Test your Views
Jorge Ortiz
 
PDF
Control your Voice like a Bene Gesserit
Jorge Ortiz
 
PDF
Kata gilded rose en Golang
Jorge Ortiz
 
PDF
CYA: Cover Your App
Jorge Ortiz
 
PDF
Refactor your way forward
Jorge Ortiz
 
PDF
201710 Fly Me to the View - iOS Conf SG
Jorge Ortiz
 
PDF
Home Improvement: Architecture & Kotlin
Jorge Ortiz
 
PDF
Architectural superpowers
Jorge Ortiz
 
PDF
Escape from Mars
Jorge Ortiz
 
PDF
Why the Dark Side should use Swift and a SOLID Architecture
Jorge Ortiz
 
PDF
Dependence day insurgence
Jorge Ortiz
 
PDF
Architectural superpowers
Jorge Ortiz
 
PDF
TDD for the masses
Jorge Ortiz
 
PDF
Building for perfection
Jorge Ortiz
 
PDF
TDD by Controlling Dependencies
Jorge Ortiz
 
PDF
Core Data in Modern Times
Jorge Ortiz
 
PDF
7 stages of unit testing
Jorge Ortiz
 
PDF
Travel with your mock server
Jorge Ortiz
 
PDF
Kata tdd
Jorge Ortiz
 
Tell Me Quando - Implementing Feature Flags
Jorge Ortiz
 
Unit Test your Views
Jorge Ortiz
 
Control your Voice like a Bene Gesserit
Jorge Ortiz
 
Kata gilded rose en Golang
Jorge Ortiz
 
CYA: Cover Your App
Jorge Ortiz
 
Refactor your way forward
Jorge Ortiz
 
201710 Fly Me to the View - iOS Conf SG
Jorge Ortiz
 
Home Improvement: Architecture & Kotlin
Jorge Ortiz
 
Architectural superpowers
Jorge Ortiz
 
Escape from Mars
Jorge Ortiz
 
Why the Dark Side should use Swift and a SOLID Architecture
Jorge Ortiz
 
Dependence day insurgence
Jorge Ortiz
 
Architectural superpowers
Jorge Ortiz
 
TDD for the masses
Jorge Ortiz
 
Building for perfection
Jorge Ortiz
 
TDD by Controlling Dependencies
Jorge Ortiz
 
Core Data in Modern Times
Jorge Ortiz
 
7 stages of unit testing
Jorge Ortiz
 
Travel with your mock server
Jorge Ortiz
 
Kata tdd
Jorge Ortiz
 

Recently uploaded (20)

PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
PDF
Simplify React app login with asgardeo-sdk
vaibhav289687
 
PPTX
Library_Management_System_PPT111111.pptx
nmtnissancrm
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PPTX
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
PDF
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
Simplify React app login with asgardeo-sdk
vaibhav289687
 
Library_Management_System_PPT111111.pptx
nmtnissancrm
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 

iOS advanced architecture workshop 3h edition