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
VIPER Architecture から学ぶ Dependency Injection
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
star__hoshi
July 26, 2017
Technology
2.3k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
VIPER Architecture から学ぶ Dependency Injection
iOS Test Night #5 - connpass
https://testnight.connpass.com/event/59283/
star__hoshi
July 26, 2017
More Decks by star__hoshi
See All by star__hoshi
大統一ロガーを利用したサービス開発
starhoshi
0
3.4k
Komerco-コメルコ-を支える技術
starhoshi
4
6.1k
実践 Cloud Functions for Firebase
starhoshi
7
5.9k
個人アプリでレビューを高くするためにやっていること
starhoshi
2
1.8k
個人開発を加速させるツール群
starhoshi
54
22k
fastlane 勉強会
starhoshi
0
870
学校の iOS 端末事情
starhoshi
0
2.4k
iOS が fastlane なら Android も fastlane に乗ってみては?
starhoshi
0
3k
iOS 開発での Pull Request と テストカバレッジの連携
starhoshi
4
3.5k
Other Decks in Technology
See All in Technology
FPGAの開発コンペでZephyrを使ってみた
iotengineer22
0
140
フィジカル版Github Onshapeの紹介
shiba_8ro
0
290
AI駆動開発を通して感じた、 AI時代のデザイナーの役割変化
whisaiyo
4
2.3k
2026TECHFRESH畢業分享會 - 原生還是跨平台? App 開發踩坑實錄
line_developers_tw
PRO
0
1.3k
SteampipeとExcel Power QueryでAWS構成定義書の作成を自動化する
jhashimoto
0
160
Kiroで書いた 設計書 が AI レビューの 採点基準 になる
ezaki
0
130
エラーバジェットのアラートのタイミングを考える.pdf
kairim0
0
170
不要なレビューをAIにまかせて AIコーディングの環境改善を加速した
shoota
1
230
アンオフィシャルな、オフィシャルからのお願い
wyamazak_devrel
0
140
Claude Codeをどのように キャッチアップしているか
oikon48
13
8.6k
[チョークトーク資料]AWS DevOps Agent を使いこなす / AWS Dev Ops Agent Chalk Talk AWS Summit Japan 2026
kinunori
3
570
Agile and AI Redmine Japan 2026
hiranabe
3
290
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
55
10k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
620
Six Lessons from altMBA
skipperchong
29
4.3k
Code Review Best Practice
trishagee
74
20k
The Language of Interfaces
destraynor
162
27k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
210
Transcript
VIPER Architecture ͔ΒֶͿ Dependency Injection iOS Test Night #5
ࣗݾհ • ຊ໊: ݈հ • Github: starhoshi • Twitter: @star__hoshi
• Classi גࣜձࣾ • -> 8/1 ͔Β ʁʁʁ
VIPER ͷ Router ʹ͍ͭͯ IUUQTDIFFTFDBLFMBCTDPNCMPHJPTQSPKFDU BSDIJUFDUVSFVTJOHWJQFS
ͬ͘͟Γ VIPER • View • Interactor • Presenter • Entity
• Router
ͬ͘͟Γ VIPER • View - UIViewController • Interactor - UseCase(Business
Logic) • Presenter - View ͱ Interactor Λհ • Entity - Data Structure • Router - ը໘ભҠͱ Dependency Injection
ͬ͘͟Γ VIPER • View - UIViewController • Interactor - UseCase(Business
Logic) • Presenter - View ͱ Interactor Λհ • Entity - Data Structure • Router - ը໘ભҠͱ Dependency Injection
Router ͷׂ • ը໘ભҠ • ը໘ભҠͱ Dependency Injection
͜Μͳ͔Μ͡ IUUQTDIFFTFDBLFMBCTDPNCMPHJPTQSPKFDU BSDIJUFDUVSFVTJOHWJQFS
͕࣌ؒͳ͍ͷͰ ཧղ͘͢͢͠ΔͨΊ View, Presenter, Router ͚ͩݟ͍͖ͯ·͢
View protocol UserView: class { var presenter: UserPresentation { get
} init(presenter: UserPresentation) } final class UserViewController: UIViewController, UserView { let presenter: UserPresentation init(presenter: UserPresentation) { self.presenter = presenter } }
Presenter protocol UserPresentation: class { var router: UserWireframe { get
} init(router: UserWireframe) } final class UserPresenter: UserPresentation { let router: UserWireframe init(router: UserWireframe) { self.router = router } }
Router protocol UserWireframe: class { static func assembleModule() -> UIViewController
} final class UserRouter: UserWireframe { static func assembleModule() -> UIViewController { let router = UserRouter() let presenter = UserPresenter(router: router) let view = UserViewController(presenter: presenter) return view } }
ؔੑ • நʹґଘ͍ͯ͠Δ • ͦΕͧΕ͕ Protocol Λ࣮͠ɺ Protocol ʹґଘ͍ͯ͠Δ •
Router ͚͕ͩ۩ΫϥεΛ Initialize ͍ͯ͠Δ • Router Ͱ DI ͍ͯ͠Δʂ
DI ͷୈҰา final class UserPresenter: UserPresentation { let router: UserWireframe
init(router: UserWireframe) { self.router = router } } final class UserPresenter: UserPresentation { let router: UserWireframe init() { self.router = UserRouter() } } ❌ ⭕
Կ͕خ͍͠ͷ͔
ςετ͕ॻ͖͘͢ͳͬͨ • Protocol ʹͷΈґଘ͍ͯ͠Δ • Mock ΫϥεΛ࡞ΕΔ • ґଘؔͷগͳ͍ Testable
ͳΞʔΩςΫνϟʹ • ଞͷΞʔΩςΫνϟͰԠ༻Ͱ͖Δ
ςετίʔυ class UserPresenterSpec: QuickSpec { override func spec() { let
router = MockUserRouter() let presenter = UserPresenter(router: router) describe("viewDidLoad") { beforeEach { presenter.viewDidLoad() } it("…") { … } } } }
͖ͬ͞ͷίʔυ • ͍Ζ͍ΖંͬͯΔ • Presenter ͔Β View ʹ͑ΒΕͳ͍ͱ͔ • Router
͕ը໘ભҠͰ͖ͳ͍ͱ͔ • ͦͦίϯύΠϧ௨Βͳ͍
ਅ໘ʹ VIPER ͨ͠ίʔυ IUUQTHJUIVCDPNTUBSIPTIJ%FWJDF8BMMQBQFS
AppStore ʹग़ͯΔ
None
https://iosdc.jp/2017/node/1543 Stub ͱ Mock ͷҧ͍ɺͪΌΜ ͱཧղͰ͖͍ͯ·͔͢ʁ
VIPER Architecture ͔ΒֶͿ Dependency Injection
Ҏ্