Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
iOSDevUK 2015: Clean Code through Dependency In...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
AppFoundry
September 15, 2015
Programming
2
650
iOSDevUK 2015: Clean Code through Dependency Injection
This is a 5 minute fast-talk we gave at iOSDevUK 2015.
AppFoundry
September 15, 2015
Tweet
Share
More Decks by AppFoundry
See All by AppFoundry
Introductie iOS - Jens
appfoundrybe
0
110
Android In Practice
appfoundrybe
0
140
Android Introduction 3.0 by Siebe
appfoundrybe
0
120
Android in Practice (long)
appfoundrybe
0
210
React Native - cross-platform mobile app development
appfoundrybe
0
190
React Native Storybook
appfoundrybe
0
480
the ionic crash course
appfoundrybe
1
190
View based apps with Conductor
appfoundrybe
0
650
Android Accessibility at GDG Devfest Brussels 2016
appfoundrybe
0
650
Other Decks in Programming
See All in Programming
AI時代の認知負荷との向き合い方
optfit
0
150
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
600
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
400
dchart: charts from deck markup
ajstarks
3
990
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.5k
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
110
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
610
Grafana:建立系統全知視角的捷徑
blueswen
0
330
CSC307 Lecture 09
javiergs
PRO
1
830
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
3.8k
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
Featured
See All Featured
Practical Orchestrator
shlominoach
191
11k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
So, you think you're a good person
axbom
PRO
2
1.9k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
640
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
350
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
140
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.9k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Building Applications with DynamoDB
mza
96
6.9k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
The Curious Case for Waylosing
cassininazir
0
230
Transcript
Clean Code through Dependency Injection
Your host Mike Seghers Developer/Architect
[email protected]
@mikeseghers
Creating apps: a recent history
2012
Coding Example Acceptable in 2012 struct SkeumorphicDesigner { func createDesign(requirements:
Requirements) -> Design { //Draws some boxes with stitches, applies colors //returns Design } } struct ObjectiveCDeveloper { func createApp(requirements: Requirements, design: Design) -> App { //Does some code between [], applies the design using //InterfaceBuilder, returns App }
Coding Example Acceptable in 2012 class AppFactory2012 { private let
developer:ObjectiveCDeveloper private let designer:SkeumorphicDesigner init() { developer = ObjectiveCDeveloper() designer = SkeumorphicDesigner() } public func createApp(requirements:Requirements) -> App { let design = designer.createDesign(requirements) return developer.createApp(requirements, design: design) } } … let appFactory = AppFactory2012() let app = appFactory.createApp(requirements)
2013
Coding Example Acceptable in 2013 struct FlatDesigner { func createDesign(requirements:
Requirements) -> Design { //Draws some flat boxes, applies less color, returns Design } } struct ObjectiveCDeveloper { … }
Coding Example Acceptable in 2013 class AppFactory2013 { private let
developer:ObjectiveCDeveloper private let designer:FlatDesigner init() { developer = ObjectiveCDeveloper() designer = FlatDesigner() } public func createApp(requirements:Requirements) -> App { let design = designer.createDesign(requirements) return developer.createApp(requirements, design: design) } } … let appFactory = AppFactory2013() let app = appFactory.createApp(requirements)
Current
Coding Example Acceptable in now struct SwiftDeveloper { func createApp(requirements:
Requirements, design: Design) -> App { //Does some code without semi-colons, applies the //design using StoryBoards, returns App } struct FlatDesigner { … }
Coding Example Acceptable in now class AppFactory2014 { private let
developer:SwiftDeveloper private let designer:FlatDesigner init() { developer = SwiftDeveloper() designer = FlatDesigner() } public func createApp(requirements:Requirements) -> App { let design = designer.createDesign(requirements) return developer.createApp(requirements, design: design) } } … let appFactory = AppFactory2014() let app = appFactory.createApp(requirements)
How many app factories does one need?
Coding Example Acceptable all the time protocol Designer { func
createDesign(requirements: Requirements) -> Design } protocol Developer { func createApp(requirements: Requirements, design: Design) -> App } extension SkeumorphicDesigner : Designer {} extension FlatDesigner : Designer {} extension ObjectiveCDeveloper : Developer {} extension SwiftDeveloper : Developer {}
Coding Example Acceptable all the time class AppFoundry { private
let developer:Developer private let designer:Designer init(developer: Developer, designer: Designer) { self.developer = developer self.designer = designer } func createApp(requirements:Requirements) -> App { let design = designer.createDesign(requirements) return developer.createApp(requirements, design: design) } }
Coding Example Acceptable all the time let developer = ObjectiveCDeveloper()
let designer = SkeumorphicDesigner() let oldSchoolFoundry = AppFoundry(developer: developer, designer: designer) oldSchoolFoundry.createApp(requirements)
Coding Example Acceptable all the time let developer = ObjectiveCDeveloper()
let designer = FlatDesigner() let playingItSaveFoundry = AppFoundry(developer: developer, designer: designer) playingItSaveFoundry.createApp(requirements)
Dependency Injection
Helps with reusable code
Dependency Injection
Helps with loose coupling
Dependency Injection
Helps with (unit) tests
Dependency Injection
Helps keep your code clean
Questions? Come talk to me! Mike Seghers Developer/Architect
[email protected]
@mikeseghers
https://github.com/appfoundry/Reliant