Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
DI整備でneedleを使った話
Search
kamui_project
October 31, 2022
Technology
0
290
DI整備でneedleを使った話
kamui_project
October 31, 2022
Tweet
Share
More Decks by kamui_project
See All by kamui_project
String Catalog
tony1224
1
2.3k
meetup_201910.pdf
tony1224
0
170
potatotips_201906.pdf
tony1224
0
83
potatotips_201905.pdf
tony1224
1
480
andfactory_201903.pdf
tony1224
0
1.2k
Dividing Model into layers and implementing Unit Test
tony1224
1
1.2k
WWDC18 cherry-pick Xcode 10 beta
tony1224
0
310
Other Decks in Technology
See All in Technology
AI 駆動開発勉強会 フロントエンド支部 #1 w/あずもば
1ftseabass
PRO
0
210
GitLab Duo Agent Platformで実現する“AI駆動・継続的サービス開発”と最新情報のアップデート
jeffi7
0
210
Challenging Hardware Contests with Zephyr and Lessons Learned
iotengineer22
0
120
安いGPUレンタルサービスについて
aratako
2
2.6k
生成AI時代の自動E2Eテスト運用とPlaywright実践知_引持力哉
legalontechnologies
PRO
0
210
グレートファイアウォールを自宅に建てよう
ctes091x
0
140
最近のLinux普段づかいWaylandデスクトップ元年
penguin2716
1
660
エンジニアリングマネージャー はじめての目標設定と評価
halkt
0
250
【CEDEC+KYUSHU2025】学生・若手必見!テクニカルアーティスト 大全 ~仕事・スキル・キャリアパス、TAの「わからない」を徹底解剖~
cygames
PRO
0
150
AWS Trainium3 をちょっと身近に感じたい
bigmuramura
1
130
コミューンのデータ分析AIエージェント「Community Sage」の紹介
fufufukakaka
0
440
MapKitとオープンデータで実現する地図情報の拡張と可視化
zozotech
PRO
1
120
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
56
14k
Bash Introduction
62gerente
615
210k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Visualization
eitanlees
150
16k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.3k
The Language of Interfaces
destraynor
162
25k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.8k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
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の仕組みを介す 形で実現していきたい まとめ
最後に
最後に