Dependence day insurgence

Jorge Ortiz
Jorge OrtizOwner at PoWWaU
#Swift3Arch
Dependence day:
Insurgence
Jorge D. Ortiz Fuentes
@jdortiz
A Canonical

Examples

Production
#Swift3Arch
#Swift3Arch
Agenda
The Problem
Solutions
Recommendations
The Problem
#Swift3Arch
Job Description
Understand the problem
Identify the right set of pieces
Put proper names
Make them run together properly
#Swift3Arch
Social Network Option A
Social Network
#Swift3Arch
Video
Text
Image
Social Network Option B
User PostGroup
Discussion
Promotion
DM
#Swift3Arch
Single Responsibility
Principle
View
Controller

Presenter

View Model
Model
Presentation
logic
Business
Logic
Data
Source
Data
Source
Data
Source
Navigation
The Jigsaw
Puzzle
#Swift3Arch
Making it work
Objects require other objects to work ->
Dependencies
Each object creates its dependencies
Bad idea™
• Another responsibility
• What if we want to use it with different
sets of pieces?
Instanciation
=

alien is born
Test
environment
#Swift3Arch
How to Provide
Dependencies
Initializer
Property
Method
But Who?
Frameworks to the
rescue
#Swift3Arch
Inversion of Control
Hollywood Principle
#Swift3Arch
Dependency Inversion
Containers
Dip
Swinject
Cleanse
#Swift3Arch
Dip
Created by Olivier Halligon, maintained by Ilya
Puchka
Beautifully simple
Nice way to inject in Storyboards
Scopes, Named definitions, Runtime arguments,
Circular dependencies, Auto-wiring & Auto-injection,
Type forwarding, Storyboards integration, Weakly
typed components, Easy configuration, Thread
safety, Helpful error messages, and configuration
validation.
#Swift3Arch
Dip
func configure(container: DependencyContainer) {
container.register(.unique) { InMemoryRepo() }
container.register(.unique) { try UseCaseFactory(entityGateway:
container.resolve() as InMemoryRepo) }
DependencyContainer.uiContainers = [showProgrammersListModule]
}
let showProgrammersListModule = DependencyContainer { container in
container.register() { try ProgrammersListPresenter(useCaseFactory:
container.resolve() as UseCaseFactory) }
container.register(tag: "ProgrammersTableVC")
{ ProgrammersTableViewController() }
.resolvingProperties { container, viewController in
viewController.presenter = try container.resolve() as
ProgrammersListPresenter
}
}
extension ProgrammersTableViewController: StoryboardInstantiatable {}
#Swift3Arch
Swinject
Created by Jakub Vano, Wolfgang Lutz, Yoichi
Tagala
Pure Swift Type Support, Injection with
Arguments, Initializer/Property/Method
Injections, Initialization Callback, Circular
Dependencies, Object Scopes, Reference &
Value Types, Self-registration, Container
Hierarchy, Property Injection from Resource
files, Thread Safety, Modular Components,
Storyboard
#Swift3Arch
Cleanse
Created by Square
Early version, but promising
No Swift 3
Yet*!
The World Outside
#Swift3Arch
Java for Android
Standard annotations for DI (JSR330)
Introspection & Reflection
Many frameworks available
Some owned by Google (Guice & Dagger
2)
Maturity
What then?
Traditional
methods
#Swift3Arch
Assemble the Pieces
class ProgrammersListConnector {
// MARK: - Constants
let entityGateway: EntityGatewayProtocol
weak var presenter: ProgrammersListPresenter!
func assembleModule(view: ProgrammersTableViewController) {
let useCaseFactory = UseCaseFactory(entityGateway:
entityGateway)
let presenter = ProgrammersListPresenter(useCaseFactory:
useCaseFactory)
view.presenter = presenter
view.connector = self
presenter.view = view
self.presenter = presenter
}
}
#Swift3Arch
Factories are your friend
protocol UseCase { func execute() }
class UseCaseFactory {
enum Use {
case showProgrammersList(completion:
ShowProgrammersListCompletion)
// …
}
func create(useCase whichUseCase: Use) -> UseCase {
switch whichUseCase {
case let .showProgrammersList(completion: completion):
return ShowProgrammersListUseCase(entityGateway:
entityGateway, completionHandler: completion)
// …
}
}
Recap
#Swift3Arch
Take aways
Make your dependencies explicit
Use factories
Understand how it a container works
Use DI frameworks with caution
Thank
You!
@jdortiz
#Swift3Arch
1 of 33

Recommended

Why the Dark Side should use Swift and a SOLID Architecture by
Why the Dark Side should use Swift and a SOLID ArchitectureWhy the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID ArchitectureJorge Ortiz
422 views39 slides
Architectural superpowers by
Architectural superpowersArchitectural superpowers
Architectural superpowersJorge Ortiz
333 views40 slides
Rootcon X - Reverse Engineering Swift Applications by
Rootcon X - Reverse Engineering Swift ApplicationsRootcon X - Reverse Engineering Swift Applications
Rootcon X - Reverse Engineering Swift Applicationseightbit
1.4K views64 slides
Tech breakfast 18 by
Tech breakfast 18Tech breakfast 18
Tech breakfast 18James Leone
275 views13 slides
Wahckon[2] - iOS Runtime Hacking Crash Course by
Wahckon[2] - iOS Runtime Hacking Crash CourseWahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash Courseeightbit
274 views45 slides
FRIDA 101 Android by
FRIDA 101 AndroidFRIDA 101 Android
FRIDA 101 AndroidTony Thomas
1.2K views20 slides

More Related Content

What's hot

Swift GUI Development without Xcode by
Swift GUI Development without XcodeSwift GUI Development without Xcode
Swift GUI Development without XcodeCarl Brown
1.9K views17 slides
Better Swift from the Foundation up #tryswiftnyc17 09-06 by
Better Swift from the Foundation up #tryswiftnyc17 09-06Better Swift from the Foundation up #tryswiftnyc17 09-06
Better Swift from the Foundation up #tryswiftnyc17 09-06Carl Brown
482 views42 slides
DBI-Assisted Android Application Reverse Engineering by
DBI-Assisted Android Application Reverse EngineeringDBI-Assisted Android Application Reverse Engineering
DBI-Assisted Android Application Reverse EngineeringSahil Dhar
2.1K views35 slides
Laravel 5 and SOLID by
Laravel 5 and SOLIDLaravel 5 and SOLID
Laravel 5 and SOLIDIgor Talevski
10.2K views37 slides
Prg 421 guide focus dreams prg421guide.com by
Prg 421 guide focus dreams   prg421guide.comPrg 421 guide focus dreams   prg421guide.com
Prg 421 guide focus dreams prg421guide.comchandika6
12 views18 slides
From zero to hero with React Native! by
From zero to hero with React Native!From zero to hero with React Native!
From zero to hero with React Native!Commit University
1.3K views31 slides

What's hot(20)

Swift GUI Development without Xcode by Carl Brown
Swift GUI Development without XcodeSwift GUI Development without Xcode
Swift GUI Development without Xcode
Carl Brown1.9K views
Better Swift from the Foundation up #tryswiftnyc17 09-06 by Carl Brown
Better Swift from the Foundation up #tryswiftnyc17 09-06Better Swift from the Foundation up #tryswiftnyc17 09-06
Better Swift from the Foundation up #tryswiftnyc17 09-06
Carl Brown482 views
DBI-Assisted Android Application Reverse Engineering by Sahil Dhar
DBI-Assisted Android Application Reverse EngineeringDBI-Assisted Android Application Reverse Engineering
DBI-Assisted Android Application Reverse Engineering
Sahil Dhar2.1K views
Laravel 5 and SOLID by Igor Talevski
Laravel 5 and SOLIDLaravel 5 and SOLID
Laravel 5 and SOLID
Igor Talevski10.2K views
Prg 421 guide focus dreams prg421guide.com by chandika6
Prg 421 guide focus dreams   prg421guide.comPrg 421 guide focus dreams   prg421guide.com
Prg 421 guide focus dreams prg421guide.com
chandika612 views
Try! Swift Tokyo2017 by Amy Cheong
Try! Swift Tokyo2017Try! Swift Tokyo2017
Try! Swift Tokyo2017
Amy Cheong211 views
Implementation of TypeGraphQL with Apollo Server by Fabien Pasquet
Implementation of TypeGraphQL with Apollo ServerImplementation of TypeGraphQL with Apollo Server
Implementation of TypeGraphQL with Apollo Server
Fabien Pasquet59 views
Android Malware and Machine Learning by caleb194331
Android Malware and Machine LearningAndroid Malware and Machine Learning
Android Malware and Machine Learning
caleb194331115 views
Android Deobfuscation: Tools and Techniques by caleb194331
Android Deobfuscation: Tools and TechniquesAndroid Deobfuscation: Tools and Techniques
Android Deobfuscation: Tools and Techniques
caleb194331503 views
Bootstrapping iPhone Development by ThoughtWorks
Bootstrapping iPhone DevelopmentBootstrapping iPhone Development
Bootstrapping iPhone Development
ThoughtWorks832 views
Steve Sfartz - How to embed Messaging and Video in your apps - Codemotion Mil... by Codemotion
Steve Sfartz - How to embed Messaging and Video in your apps - Codemotion Mil...Steve Sfartz - How to embed Messaging and Video in your apps - Codemotion Mil...
Steve Sfartz - How to embed Messaging and Video in your apps - Codemotion Mil...
Codemotion450 views
ProbeDroid - Crafting Your Own Dynamic Instrument Tool on Android for App Beh... by ZongXian Shen
ProbeDroid - Crafting Your Own Dynamic Instrument Tool on Android for App Beh...ProbeDroid - Crafting Your Own Dynamic Instrument Tool on Android for App Beh...
ProbeDroid - Crafting Your Own Dynamic Instrument Tool on Android for App Beh...
ZongXian Shen2.9K views
DIC To The Limit – deSymfonyDay, Barcelona 2014 by Ronny López
DIC To The Limit – deSymfonyDay, Barcelona 2014DIC To The Limit – deSymfonyDay, Barcelona 2014
DIC To The Limit – deSymfonyDay, Barcelona 2014
Ronny López1K views
How to reverse engineer Android applications by hubx
How to reverse engineer Android applicationsHow to reverse engineer Android applications
How to reverse engineer Android applications
hubx519 views
How to build a tool for operating Flink on Kubernetes by AndreaMedeghini
How to build a tool for operating Flink on KubernetesHow to build a tool for operating Flink on Kubernetes
How to build a tool for operating Flink on Kubernetes
AndreaMedeghini453 views
Refactoring a go project by Dan Tran
Refactoring a go projectRefactoring a go project
Refactoring a go project
Dan Tran1.2K views
Android reverse engineering - Analyzing skype by Mário Almeida
Android reverse engineering - Analyzing skypeAndroid reverse engineering - Analyzing skype
Android reverse engineering - Analyzing skype
Mário Almeida6.6K views
All you need is Zap - Omer Levi Hevroni & Yshay Yaacobi - DevOpsDays Tel Aviv... by DevOpsDays Tel Aviv
All you need is Zap - Omer Levi Hevroni & Yshay Yaacobi - DevOpsDays Tel Aviv...All you need is Zap - Omer Levi Hevroni & Yshay Yaacobi - DevOpsDays Tel Aviv...
All you need is Zap - Omer Levi Hevroni & Yshay Yaacobi - DevOpsDays Tel Aviv...

Similar to Dependence day insurgence

Java for android developers by
Java for android developersJava for android developers
Java for android developersAly Abdelkareem
770 views95 slides
Qb it1301 by
Qb   it1301Qb   it1301
Qb it1301ArthyR3
127 views84 slides
CS8392 OOP by
CS8392 OOPCS8392 OOP
CS8392 OOPDhanalakshmiVelusamy1
1K views89 slides
Java basic by
Java basicJava basic
Java basicPooja Thakur
1.5K views109 slides
Computer Science And Engineering, Amity University, Noida... by
Computer Science And Engineering, Amity University, Noida...Computer Science And Engineering, Amity University, Noida...
Computer Science And Engineering, Amity University, Noida...Asia Grover
2 views44 slides
oop unit1.pptx by
oop unit1.pptxoop unit1.pptx
oop unit1.pptxsureshkumara29
9 views89 slides

Similar to Dependence day insurgence(20)

Qb it1301 by ArthyR3
Qb   it1301Qb   it1301
Qb it1301
ArthyR3127 views
Computer Science And Engineering, Amity University, Noida... by Asia Grover
Computer Science And Engineering, Amity University, Noida...Computer Science And Engineering, Amity University, Noida...
Computer Science And Engineering, Amity University, Noida...
Asia Grover2 views
Stuxnet redux. malware attribution & lessons learned by Yury Chemerkin
Stuxnet redux. malware attribution & lessons learnedStuxnet redux. malware attribution & lessons learned
Stuxnet redux. malware attribution & lessons learned
Yury Chemerkin1.2K views
Framework engineering JCO 2011 by YoungSu Son
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011
YoungSu Son1.6K views
Toward dynamic analysis of obfuscated android malware by ZongXian Shen
Toward dynamic analysis of obfuscated android malwareToward dynamic analysis of obfuscated android malware
Toward dynamic analysis of obfuscated android malware
ZongXian Shen3.9K views
Java Faqs useful for freshers and experienced by yearninginjava
Java Faqs useful for freshers and experiencedJava Faqs useful for freshers and experienced
Java Faqs useful for freshers and experienced
yearninginjava1.4K views
All of javascript by Togakangaroo
All of javascriptAll of javascript
All of javascript
Togakangaroo1.7K views
Object Oriented Programming-JAVA by Home
Object Oriented Programming-JAVAObject Oriented Programming-JAVA
Object Oriented Programming-JAVA
Home3.1K views
best java training center in chennai by sathis est
best java training center in chennaibest java training center in chennai
best java training center in chennai
sathis est72 views
Top 371 java fa qs useful for freshers and experienced by Gaurav Maheshwari
Top 371 java fa qs useful for freshers and experiencedTop 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experienced
Gaurav Maheshwari807 views
Top 10 Java Interview Questions and Answers 2014 by iimjobs and hirist
Top 10 Java Interview Questions and Answers 2014 Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014
iimjobs and hirist10.5K views
Java interview questions and answers for cognizant By Data Council Pune by Pankaj kshirsagar
Java interview questions and answers for cognizant By Data Council PuneJava interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council Pune
Pankaj kshirsagar107 views

More from Jorge Ortiz

Tell Me Quando - Implementing Feature Flags by
Tell Me Quando - Implementing Feature FlagsTell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature FlagsJorge Ortiz
118 views34 slides
Unit Test your Views by
Unit Test your ViewsUnit Test your Views
Unit Test your ViewsJorge Ortiz
222 views24 slides
Control your Voice like a Bene Gesserit by
Control your Voice like a Bene GesseritControl your Voice like a Bene Gesserit
Control your Voice like a Bene GesseritJorge Ortiz
476 views47 slides
Kata gilded rose en Golang by
Kata gilded rose en GolangKata gilded rose en Golang
Kata gilded rose en GolangJorge Ortiz
391 views50 slides
CYA: Cover Your App by
CYA: Cover Your AppCYA: Cover Your App
CYA: Cover Your AppJorge Ortiz
343 views34 slides
Refactor your way forward by
Refactor your way forwardRefactor your way forward
Refactor your way forwardJorge Ortiz
477 views69 slides

More from Jorge Ortiz(20)

Tell Me Quando - Implementing Feature Flags by Jorge Ortiz
Tell Me Quando - Implementing Feature FlagsTell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature Flags
Jorge Ortiz118 views
Unit Test your Views by Jorge Ortiz
Unit Test your ViewsUnit Test your Views
Unit Test your Views
Jorge Ortiz222 views
Control your Voice like a Bene Gesserit by Jorge Ortiz
Control your Voice like a Bene GesseritControl your Voice like a Bene Gesserit
Control your Voice like a Bene Gesserit
Jorge Ortiz476 views
Kata gilded rose en Golang by Jorge Ortiz
Kata gilded rose en GolangKata gilded rose en Golang
Kata gilded rose en Golang
Jorge Ortiz391 views
CYA: Cover Your App by Jorge Ortiz
CYA: Cover Your AppCYA: Cover Your App
CYA: Cover Your App
Jorge Ortiz343 views
Refactor your way forward by Jorge Ortiz
Refactor your way forwardRefactor your way forward
Refactor your way forward
Jorge Ortiz477 views
201710 Fly Me to the View - iOS Conf SG by Jorge Ortiz
201710 Fly Me to the View - iOS Conf SG201710 Fly Me to the View - iOS Conf SG
201710 Fly Me to the View - iOS Conf SG
Jorge Ortiz699 views
Home Improvement: Architecture & Kotlin by Jorge Ortiz
Home Improvement: Architecture & KotlinHome Improvement: Architecture & Kotlin
Home Improvement: Architecture & Kotlin
Jorge Ortiz461 views
Architectural superpowers by Jorge Ortiz
Architectural superpowersArchitectural superpowers
Architectural superpowers
Jorge Ortiz195 views
Architecting Alive Apps by Jorge Ortiz
Architecting Alive AppsArchitecting Alive Apps
Architecting Alive Apps
Jorge Ortiz537 views
iOS advanced architecture workshop 3h edition by Jorge Ortiz
iOS advanced architecture workshop 3h editioniOS advanced architecture workshop 3h edition
iOS advanced architecture workshop 3h edition
Jorge Ortiz583 views
Android clean architecture workshop 3h edition by Jorge Ortiz
Android clean architecture workshop 3h editionAndroid clean architecture workshop 3h edition
Android clean architecture workshop 3h edition
Jorge Ortiz743 views
To Protect & To Serve by Jorge Ortiz
To Protect & To ServeTo Protect & To Serve
To Protect & To Serve
Jorge Ortiz925 views
Clean architecture workshop by Jorge Ortiz
Clean architecture workshopClean architecture workshop
Clean architecture workshop
Jorge Ortiz732 views
Escape from Mars by Jorge Ortiz
Escape from MarsEscape from Mars
Escape from Mars
Jorge Ortiz350 views
TDD for the masses by Jorge Ortiz
TDD for the massesTDD for the masses
TDD for the masses
Jorge Ortiz706 views
7 Stages of Unit Testing in iOS by Jorge Ortiz
7 Stages of Unit Testing in iOS7 Stages of Unit Testing in iOS
7 Stages of Unit Testing in iOS
Jorge Ortiz805 views
Building for perfection by Jorge Ortiz
Building for perfectionBuilding for perfection
Building for perfection
Jorge Ortiz685 views
TDD by Controlling Dependencies by Jorge Ortiz
TDD by Controlling DependenciesTDD by Controlling Dependencies
TDD by Controlling Dependencies
Jorge Ortiz854 views
Unit testing in swift 2 - The before & after story by Jorge Ortiz
Unit testing in swift 2 - The before & after storyUnit testing in swift 2 - The before & after story
Unit testing in swift 2 - The before & after story
Jorge Ortiz991 views

Recently uploaded

Quality Assurance by
Quality Assurance Quality Assurance
Quality Assurance interworksoftware2
5 views6 slides
AI and Ml presentation .pptx by
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptxFayazAli87
14 views15 slides
360 graden fabriek by
360 graden fabriek360 graden fabriek
360 graden fabriekinfo33492
162 views25 slides
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action by
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionMárton Kodok
16 views55 slides
Dapr Unleashed: Accelerating Microservice Development by
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice DevelopmentMiroslav Janeski
13 views29 slides
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx by
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptxanimuscrm
15 views19 slides

Recently uploaded(20)

AI and Ml presentation .pptx by FayazAli87
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptx
FayazAli8714 views
360 graden fabriek by info33492
360 graden fabriek360 graden fabriek
360 graden fabriek
info33492162 views
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action by Márton Kodok
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action
Márton Kodok16 views
Dapr Unleashed: Accelerating Microservice Development by Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski13 views
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx by animuscrm
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
animuscrm15 views
JioEngage_Presentation.pptx by admin125455
JioEngage_Presentation.pptxJioEngage_Presentation.pptx
JioEngage_Presentation.pptx
admin1254558 views
predicting-m3-devopsconMunich-2023-v2.pptx by Tier1 app
predicting-m3-devopsconMunich-2023-v2.pptxpredicting-m3-devopsconMunich-2023-v2.pptx
predicting-m3-devopsconMunich-2023-v2.pptx
Tier1 app11 views
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated... by TomHalpin9
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
TomHalpin96 views
Sprint 226 by ManageIQ
Sprint 226Sprint 226
Sprint 226
ManageIQ11 views
Top-5-production-devconMunich-2023.pptx by Tier1 app
Top-5-production-devconMunich-2023.pptxTop-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptx
Tier1 app9 views
predicting-m3-devopsconMunich-2023.pptx by Tier1 app
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptx
Tier1 app8 views
FIMA 2023 Neo4j & FS - Entity Resolution.pptx by Neo4j
FIMA 2023 Neo4j & FS - Entity Resolution.pptxFIMA 2023 Neo4j & FS - Entity Resolution.pptx
FIMA 2023 Neo4j & FS - Entity Resolution.pptx
Neo4j17 views

Dependence day insurgence