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
660
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
iOSDevUK 2015: Clean Code through Dependency Injection
This is a 5 minute fast-talk we gave at iOSDevUK 2015.
AppFoundry
September 15, 2015
More Decks by AppFoundry
See All by AppFoundry
Introductie iOS - Jens
appfoundrybe
0
120
Android In Practice
appfoundrybe
0
150
Android Introduction 3.0 by Siebe
appfoundrybe
0
140
Android in Practice (long)
appfoundrybe
0
230
React Native - cross-platform mobile app development
appfoundrybe
0
210
React Native Storybook
appfoundrybe
0
490
the ionic crash course
appfoundrybe
1
200
View based apps with Conductor
appfoundrybe
0
660
Android Accessibility at GDG Devfest Brussels 2016
appfoundrybe
0
680
Other Decks in Programming
See All in Programming
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
14
5.8k
AIで効率化できた業務・日常
ochtum
0
140
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
120
dRuby over BLE
makicamel
2
390
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
290
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
2
280
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
270
エージェンティックRAGにAWSで入門しよう!
har1101
9
1.7k
さぁV100、メモリをお食べ・・・
nilpe
0
150
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
130
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
370
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
280
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
Side Projects
sachag
455
43k
GraphQLとの向き合い方2022年版
quramy
50
15k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
360
The Curse of the Amulet
leimatthew05
2
13k
Facilitating Awesome Meetings
lara
57
7k
Ethics towards AI in product and experience design
skipperchong
2
310
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
750
Un-Boring Meetings
codingconduct
0
320
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