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
DI整備でneedleを使った話
Search
kamui_project
October 31, 2022
Technology
310
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
DI整備でneedleを使った話
kamui_project
October 31, 2022
More Decks by kamui_project
See All by kamui_project
String Catalog
tony1224
1
2.4k
meetup_201910.pdf
tony1224
0
180
potatotips_201906.pdf
tony1224
0
94
potatotips_201905.pdf
tony1224
1
490
andfactory_201903.pdf
tony1224
0
1.3k
Dividing Model into layers and implementing Unit Test
tony1224
1
1.2k
WWDC18 cherry-pick Xcode 10 beta
tony1224
0
340
Other Decks in Technology
See All in Technology
新規事業を牽引する技術選定 〜フルスタックTypeScript開発の実践事例〜
nullnull
3
360
AIプラットフォームを運用し続けるための可観測性
tanimuyk
4
1.1k
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.5k
「速く作る」から「正しく作る」へ ─ 生成AI時代の開発フロー改革の ロードマップと実行 ─
starfish719
0
8.3k
AI と創る新たな世界 / A New World Created with AI
ks91
PRO
0
120
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
1.9k
noUncheckedIndexedAccess、3時間、1万円。 / noUncheckedIndexedAccess, 3 Hours, 10,000 JPY.
kaonavi
1
320
Ruby::Boxでできること、Refinementsでできること
joker1007
3
400
AI フレンドリーなエラー監視を TypeScript で実現する
shinyaigeek
2
270
Platform engineering for developers, architects & the rest of us (AI agents)
danielbryantuk
0
190
そのPoC、何を検証したつもりでしたか? AIプロダクトの価値検証で陥った落とし穴
techtekt
PRO
0
150
Djangoユーザが知っ得なPostgreSQL機能 - 設計の選択肢を増やす / Djang-use-PostgreSQL
soudai
PRO
0
200
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
6.9k
Designing Powerful Visuals for Engaging Learning
tmiket
1
400
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
600
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
190
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2k
Being A Developer After 40
akosma
91
590k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
230
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
770
Marketing to machines
jonoalderson
1
5.4k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
How to train your dragon (web standard)
notwaldorf
97
6.7k
Transcript
DI整備でneedleを使った話 2022/10/31 #79 potatotips
自己紹介 name: かむい @kamui_project company: REALITY Inc. potato tips latest
presentation: #62
弊社のDI整備のお話
note紹介 第1弾: needleでDI改善に取り組み始めた話 第2弾: needleでモジュール間の画面遷移を実 現した話 第3弾: ↑をSwiftUIで実現した話 「REALITY needle」
で検索すると出てきます
プロダクト環境の背景 リリース: 2018/8/4〜現在 主な出来事: 機能拡充, iOS新技術の積極採用, EN積極採用 View作成: UIKit →
SwiftUI / UIKit チーム文化: プレゼンテーションロジックのUnit Testは 積極的に書いている
プロダクト環境の背景 リリース: 2018/8/4〜現在 主な出来事: 機能拡充, iOS新技術の積極採用, EN積極採用 View作成: UIKit →
SwiftUI / UIKit チーム文化: プレゼンテーションロジックのUnit Testは 積極的に書いている → initializerのパラメータにデフォルト引数が 有ったり無かったり → Bastard Injection
Bastard Injection • DIのアンチパタン • デフォルト引数 → Testabilityの観点では問題は無い • DIの動機として他クラスへの依存を減らしたい
◦ 依存対象をI/Fに留めたい ◦ 結合が強くなる 弊社のDI整備 ⇨ Bastard Injectionの解消 + DIルールの整理 • DIルールの整理 ◦ 依存はI/Fに留める, ViewControllerの初期化ルール 等 ▪ 依存解決のためのコードを書く手間🤔 ▪ コンパイラセーフ🤔 DIの課題と整備
None
• オブジェクト間の依存解決コードをコンパイル時に自動 生成してくれるツール ◦ AndroidのDaggerと似ている ◦ コンパイル時にDI注入の安全性を確保 ▪ 自信を持ってコード変更ができる •
DI構造が階層的且つ実装上の登場人物が少なくシンプル • 誤ったDI注入があった際には問題箇所の変数名・型・階 層をエラー文で教えてくれる とは
とは https://github.com/uber/needle/blob/master/README.md
とは https://note.com/reality_eng/n/n124fd7da93c3
とは https://note.com/reality_eng/n/n124fd7da93c3
現在の状況と今後の展望 https://note.com/reality_eng/n/n124fd7da93c3
現在の状況と今後の展望 https://note.com/reality_eng/n/nbe40c0e17690
現在の状況と今後の展望
• 課題: Bastard InjectionなDIをしていた箇所が多く存在 • アクション: DIの整備を進めていく中で、依存問題解決のコー ド生成をneedleを使い自動化 • 現状:
起動画面ほか複数の画面で導入・拡充を進める • 今後の展望: モジュール間の画面遷移もneedleの仕組みを介す 形で実現していきたい まとめ
最後に
最後に