SlideShare a Scribd company logo
#Swift3Arch
Implementing Clean
Architecture in iOS
Jorge D. Ortiz-Fuentes
@jdortiz
A Canonical
Examples
production
#Swift3Arch
#Swift3Arch
Agenda
★ Goals
★ Before Clean Architecture
★ Clean Architecture Concepts
★ Implementation rules
★ Example App: RealProgrammers
★ Implement 1st User Story
★ References
#Swift3Arch
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
#Swift3Arch
LIVE Online Training
★ 3 days (same weekday 3 continuous weeks)
★ Máx 10 people
★ 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
#Swift3Arch
Goals
★ Understand the concepts
★ Learn the sources
★ Implement the ideas of the Clean
Architecture in a real app
★ Grow from here
Looking for
volunteer
Before Clean
Architecture
Warning:
Background Ahead!
#Swift3Arch
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.”
#Swift3Arch
Tricky question
★ If [Model] + [View] + [Controller /
Presenter / View Model] = [TheApp]
★ How can Controller != Presenter != View
Model?
★ Responsibilities matter!
★ Other components (patterns) might be
involved.
#Swift3Arch
The goal
★ Separation of responsibilities into roles. Is
it? Not historically. Other motivations.
Solving problem d’jour.
★ Now why?
• Testability
• Reusability
• Extensibility
#Swift3Arch
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)
#Swift3Arch
Apple’s MVC
★ View
• Only UIView subclasses
• Show information and handle input to generate higher level events passed to controller
• Fully reusable views library. Consistent L&F
★ Controller
• Views delegate / control what’s displayed
• Receive the events and converts them into calls to the model.
• Knows about changes in the model and update what is displayed on the view. Typically a
UIViewController. Responsible of presentation logic.
★ Model
• Contain the business logic. No references to the UI.
Flow synchronization vs Observer synchronization
MVC = Composite + Strategy + Observer
Apple’s MVC
Ctrlr
ModelView
#Swift3Arch
Apple’s 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
MVP
Presenter ModelView
Events Operations
Changes Changes
MVVM
MVVM
View Model ModelView
Events & Info Operations
Changes Changes
Clean Architecture
Concepts
#Swift3Arch
Clean Architecture
★ Uncle Bob’s (Robert C. Martin’s) architecture
★ Based in Onion, in turn based in hexagonal,
DCI and some others
Clean Architecture
App
Delegate
View (VC) Presenter Interactor
Entity
Gateway
Connector
Persistance FW
View
Network
LocationFW
Presenter
Entity Gateway
Clean Architecture
Interactor
Entity
Implementation
Rules
#Swift3Arch
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
#Swift3Arch
Features
★ Add potential candidates (Name, email, and important skills)
★ Show list of programmers 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
#Swift3Arch
MVP Features
★ Add potential candidates (Name, email, and important skills)
★ Show list of programmers 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!
#Swift3Arch
First User Story
★ Show a list of data elements to the user.
Interactor
View (VC) Presenter
Show

Programmers
Entity
Gateway
#Swift3Arch
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
Presenter
View (VC)
Programmers

List
Show

Programmers
Entity
Gateway
#Swift3Arch
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!)
View
Programmers
TableVC
Programmers

List
Show

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

List
Show

Programmers
Entity
Gateway
#Swift3Arch
Back to the Presenter
★ Implement responses to the user events.
★ Use the interactor
★ Add presentation logic to the presenter part
#Swift3Arch
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 lazy instantiation for the current date
Entity Gateway
Programmers
TableVC
Programmers

List
Show

Programmers
Entity
Gateway
#Swift3Arch
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
#Swift3Arch
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)

PPTX
Introduction to angular 2
Dor Moshe
 
PPTX
React Native
Artyom Trityak
 
PDF
From zero to hero with React Native!
Commit University
 
PPTX
Angular from a Different Angle
Jeremy Likness
 
PDF
ColdBox Hierarchical MVC - Transform Your Monolith
Ortus Solutions, Corp
 
PDF
The Continuous PHP Pipeline
Michelangelo van Dam
 
PDF
Matteo Manchi - React Native for multi-platform mobile applications - Codemot...
Codemotion
 
PPTX
Integration Testing with Selenium
All Things Open
 
PPTX
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Codemotion
 
PPTX
Automating JavaScript testing with Jasmine and Perl
nohuhu
 
PPTX
Functional programing jargon
Remo Jansen
 
PDF
Scaling up development of a modular code base
Robert Munteanu
 
PPTX
Back to the ng2 Future
Jeremy Likness
 
PDF
Conquering AngularJS Limitations
Valeri Karpov
 
PDF
WilmingtonJS - React Native Under the Hood
Justin Poliachik
 
PDF
A Separation of Concerns: Clean Architecture on Android
Outware Mobile
 
PDF
Laravel.IO A Use-Case Architecture
Shawn McCool
 
PDF
Do you really want to go fully micro?
Robert Munteanu
 
PDF
Building Better AngularJS 1.X Apps With TypeScript
ColdFusionConference
 
PPTX
Fast Track introduction to ASP.NET MVC
Ankit Kashyap
 
Introduction to angular 2
Dor Moshe
 
React Native
Artyom Trityak
 
From zero to hero with React Native!
Commit University
 
Angular from a Different Angle
Jeremy Likness
 
ColdBox Hierarchical MVC - Transform Your Monolith
Ortus Solutions, Corp
 
The Continuous PHP Pipeline
Michelangelo van Dam
 
Matteo Manchi - React Native for multi-platform mobile applications - Codemot...
Codemotion
 
Integration Testing with Selenium
All Things Open
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Codemotion
 
Automating JavaScript testing with Jasmine and Perl
nohuhu
 
Functional programing jargon
Remo Jansen
 
Scaling up development of a modular code base
Robert Munteanu
 
Back to the ng2 Future
Jeremy Likness
 
Conquering AngularJS Limitations
Valeri Karpov
 
WilmingtonJS - React Native Under the Hood
Justin Poliachik
 
A Separation of Concerns: Clean Architecture on Android
Outware Mobile
 
Laravel.IO A Use-Case Architecture
Shawn McCool
 
Do you really want to go fully micro?
Robert Munteanu
 
Building Better AngularJS 1.X Apps With TypeScript
ColdFusionConference
 
Fast Track introduction to ASP.NET MVC
Ankit Kashyap
 

Viewers also liked (20)

PDF
Introduction to VIPER Architecture
Hendy Christianto
 
PDF
Jorge D. Ortiz Fuentes "Hands on Implementation of Clean Architecture for And...
IT Event
 
PDF
iOS viper presentation
Rajat Datta
 
PDF
From mvc to viper
Krzysztof Profic
 
PPTX
VIPER - Design Pattern
Pedro Henrique Peralta
 
PPTX
iOS Coding Best Practices
Jean-Luc David
 
PDF
TDD for the masses
Jorge Ortiz
 
PDF
Architectural superpowers
Jorge Ortiz
 
PPTX
VIPER Architecture
Ahmed Lotfy
 
PPTX
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
NicheTech Com. Solutions Pvt. Ltd.
 
PDF
10 tips for a reusable architecture
Jorge Ortiz
 
PDF
Dependence day insurgence
Jorge Ortiz
 
PDF
Why the Dark Side should use Swift and a SOLID Architecture
Jorge Ortiz
 
PDF
Clear the UIViewController Mess
Giorgio Natili
 
PDF
Application architecture doesn't have to suck
jtregunna
 
PDF
"Clean" Architecture
Manfred Touron
 
PDF
Rambler.iOS #5: VIPER a la Rambler
RAMBLER&Co
 
PDF
iOS Zagreb Meetup #02 - Clean architecture in iOS apps (Leonard Beus @ Five)
Infinum
 
PPTX
[SIP 2015] iOS Proposal: VIPER
Silicon Straits
 
PDF
Infinum iOS Talks #4 - Making our VIPER more reactive
Infinum
 
Introduction to VIPER Architecture
Hendy Christianto
 
Jorge D. Ortiz Fuentes "Hands on Implementation of Clean Architecture for And...
IT Event
 
iOS viper presentation
Rajat Datta
 
From mvc to viper
Krzysztof Profic
 
VIPER - Design Pattern
Pedro Henrique Peralta
 
iOS Coding Best Practices
Jean-Luc David
 
TDD for the masses
Jorge Ortiz
 
Architectural superpowers
Jorge Ortiz
 
VIPER Architecture
Ahmed Lotfy
 
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
NicheTech Com. Solutions Pvt. Ltd.
 
10 tips for a reusable architecture
Jorge Ortiz
 
Dependence day insurgence
Jorge Ortiz
 
Why the Dark Side should use Swift and a SOLID Architecture
Jorge Ortiz
 
Clear the UIViewController Mess
Giorgio Natili
 
Application architecture doesn't have to suck
jtregunna
 
"Clean" Architecture
Manfred Touron
 
Rambler.iOS #5: VIPER a la Rambler
RAMBLER&Co
 
iOS Zagreb Meetup #02 - Clean architecture in iOS apps (Leonard Beus @ Five)
Infinum
 
[SIP 2015] iOS Proposal: VIPER
Silicon Straits
 
Infinum iOS Talks #4 - Making our VIPER more reactive
Infinum
 
Ad

Similar to Clean architecture workshop (20)

PDF
Ui design patterns
Jorge Ortiz
 
PDF
The working architecture of NodeJs applications
Viktor Turskyi
 
PPT
Mvc architecture
Surbhi Panhalkar
 
PPTX
Modern ASP.NET Webskills
Caleb Jenkins
 
PPTX
Angular js
Mauro Servienti
 
PDF
Android minutes: synchronization presentation
Javier de Pedro López
 
PDF
DCEU 18: App-in-a-Box with Docker Application Packages
Docker, Inc.
 
ODP
VIPER
Vikas Kore
 
PDF
Creating An App for 650 million customers v.2.pdf
Dmitry Osipa
 
PPTX
Angular Owin Katana TypeScript
Justin Wendlandt
 
PPTX
Leveraging Dependency Injection(DI) in Universal Applications - Tamir Dresher
Tamir Dresher
 
PDF
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav Tulach
PROIDEA
 
PPT
Mvc 130330091359-phpapp01
Jennie Gajjar
 
PDF
Cloud Powered Artificial Intelligence Evolution
Mohamed Belhassen
 
PDF
Angular2 - A story from the trenches
Johannes Rudolph
 
PPTX
Mobile App Architectures & Coding guidelines
Qamar Abbas
 
PPTX
Ios development 2
elnaqah
 
PDF
Develop Maintainable Apps - edUiConf
Annyce Davis
 
PPTX
An Introduction To Model  View  Controller In XPages
Ulrich Krause
 
PDF
Cloud Foundry Summit 2015: 12 Factor Apps For Operations
VMware Tanzu
 
Ui design patterns
Jorge Ortiz
 
The working architecture of NodeJs applications
Viktor Turskyi
 
Mvc architecture
Surbhi Panhalkar
 
Modern ASP.NET Webskills
Caleb Jenkins
 
Angular js
Mauro Servienti
 
Android minutes: synchronization presentation
Javier de Pedro López
 
DCEU 18: App-in-a-Box with Docker Application Packages
Docker, Inc.
 
VIPER
Vikas Kore
 
Creating An App for 650 million customers v.2.pdf
Dmitry Osipa
 
Angular Owin Katana TypeScript
Justin Wendlandt
 
Leveraging Dependency Injection(DI) in Universal Applications - Tamir Dresher
Tamir Dresher
 
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav Tulach
PROIDEA
 
Mvc 130330091359-phpapp01
Jennie Gajjar
 
Cloud Powered Artificial Intelligence Evolution
Mohamed Belhassen
 
Angular2 - A story from the trenches
Johannes Rudolph
 
Mobile App Architectures & Coding guidelines
Qamar Abbas
 
Ios development 2
elnaqah
 
Develop Maintainable Apps - edUiConf
Annyce Davis
 
An Introduction To Model  View  Controller In XPages
Ulrich Krause
 
Cloud Foundry Summit 2015: 12 Factor Apps For Operations
VMware Tanzu
 
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
Architecting Alive Apps
Jorge Ortiz
 
PDF
Escape from Mars
Jorge Ortiz
 
PDF
7 Stages of Unit Testing in iOS
Jorge Ortiz
 
PDF
Building for perfection
Jorge Ortiz
 
PDF
TDD by Controlling Dependencies
Jorge Ortiz
 
PDF
Unit testing in swift 2 - The before & after story
Jorge Ortiz
 
PDF
Core Data in Modern Times
Jorge Ortiz
 
PDF
Swift testing ftw
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
 
Architecting Alive Apps
Jorge Ortiz
 
Escape from Mars
Jorge Ortiz
 
7 Stages of Unit Testing in iOS
Jorge Ortiz
 
Building for perfection
Jorge Ortiz
 
TDD by Controlling Dependencies
Jorge Ortiz
 
Unit testing in swift 2 - The before & after story
Jorge Ortiz
 
Core Data in Modern Times
Jorge Ortiz
 
Swift testing ftw
Jorge Ortiz
 
7 stages of unit testing
Jorge Ortiz
 
Travel with your mock server
Jorge Ortiz
 
Kata tdd
Jorge Ortiz
 

Recently uploaded (20)

PDF
Simplify React app login with asgardeo-sdk
vaibhav289687
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Simplify React app login with asgardeo-sdk
vaibhav289687
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 

Clean architecture workshop