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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
180
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
Python札幌 LT資料
t3tra
7
1.1k
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
350
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
920
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
570
AIエージェントの設計で注意するべきポイント6選
har1101
7
3.3k
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2k
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
140
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
160
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
520
Oxlintはいいぞ
yug1224
5
1.1k
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
660
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.7k
Featured
See All Featured
Building Applications with DynamoDB
mza
96
6.9k
Navigating Weather and Climate Data
rabernat
0
75
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
Scaling GitHub
holman
464
140k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
A designer walks into a library…
pauljervisheath
210
24k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Agile that works and the tools we love
rasmusluckow
331
21k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
120
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
Context Engineering - Making Every Token Count
addyosmani
9
630
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
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