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
Dagger2 Optional bindings
Search
funnelbit
November 28, 2016
Technology
620
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Dagger2 Optional bindings
funnelbit
November 28, 2016
More Decks by funnelbit
See All by funnelbit
Hatena Engineer Seminar #9
funnelbit
5
7.5k
droidkaigi-2017-renovation
funnelbit
10
11k
Dart
funnelbit
0
300
BottomBarAndSnackBar
funnelbit
0
550
WearableRecyclerView
funnelbit
1
850
QucikSettingsTileAPI
funnelbit
0
390
Mobile Vision
funnelbit
0
490
AwarenessAPI
funnelbit
0
170
Asynchronous Injection
funnelbit
1
290
Other Decks in Technology
See All in Technology
DMMブックスのNext.js化を加速させるAI活用 / Migrating DMM Books to Next.js with AI
kentarom
0
190
アクセスキー流出時の対応で再認識した攻撃側と防御側の非対称性について
kazzpapa3
1
440
Windows の互換機能 - 古いプログラムはなぜ動作できるのか
murachiakira
PRO
0
130
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.5k
本番に近いテストをもっと手軽に - Postmanで広がるAPIテストの世界 / Expanding the World of API Testing with Postman
yokawasa
1
130
The Django UUID Story - DjangoCon US 2026
pauloxnet
0
310
[ホンマでっか SRE] あなたはなぜ SRE に?
_awache
0
360
型落ちシンクライアント端末のPoEモジュールを自作したかった話
logica0419
0
510
あなたの知らないバージョン命名規則
sat
PRO
2
850
APIセキュリティを組織で実現するには~注力する点と設計・実装に入れたい対策~
riiimparm
2
720
AI駆動開発をチームに根付かせる - 「1行も書かない」チームがHarnessを育てた1年 -
kenichirokimura
6
3.3k
指示待ちから変化に応じるClaude Codeへ!~環境からAgentへの帰り道を作る~
gotalab555
8
1.6k
Featured
See All Featured
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
500
Visualization
eitanlees
152
17k
From π to Pie charts
rasagy
0
330
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Embracing the Ebb and Flow
colly
88
5.1k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Design in an AI World
tapps
1
290
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
430
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
210
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
400
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
350
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
Transcript
%BHHFS 0QUJPOBMCJOEJOHT
ࣗݾհ ଜྋ גࣜձࣾͯͳ )BUFOBGVOOFMCJU 5XJUUFS!FYQFSPQFSP
w %SPJEP,BJHJʹొஃ͠·͢ w λΠτϧେنΞϓϦͷϦϊϕʔγϣϯ
0QUJPOBMΛఆٛ͠ ޙͰ ղܾͯ͠Β͏ !#JOET0QUJPOBM0G
!#JOET0QUJPOBM0G w 0QUJPOBMCJOEJOHΛ࣮ݱ͢Δػೳ w 0QUJPOBM5Λฦ͢ఆٛΛ༻ҙ͢Δ w ಉ͡ίϯϙʔωϯτ͔ɺαϒίϯϙʔωϯτͰ ΛຬͨͤΔ w %BHHFSd
&OUSZ public class Entry { public final String title; public
Entry(String title) { this.title = title; } }
.PEVMF BCTUSBDU @Module public abstract class MainModule { @BindsOptionalOf public
abstract Entry optionalEntryProvider(); }
$PNQPOFOU @Component(modules = {MainModule.class}) public interface MainComponent { Optional<Entry> entry();
}
.BJO"DUJWJUZ public class MainActivity extends AppCompatActivity { … MainComponent mainComponent
= DaggerMainComponent.create(); Optional<Entry> entry = mainComponent.entry(); Log.e(“entry”, entry.or(new Entry(“default")).title); … } w EFGBVMUͱදࣔ͞ΕΔ
.PEVMF @Module public class EntryModule { @Provides public Entry provideEntry()
{ return new Entry(“entry"); } }
$PNQPOFOU @Component(modules = {MainModule.class, EntryModule.class}) public interface MainComponent { Optional<Entry>
entry(); }
.BJO"DUJWJUZ public class MainActivity extends AppCompatActivity { … Optional<Entry> entry
= mainComponent.entry(); Log.e(“entry”, entry.or(new Entry(“default")).title); … } w FOUSZͱදࣔ͞ΕΔ
$PNQPOFOU ͝ͱʹ ΛมԽͤ͞Δ
&OUSZΛఏڙ͢Δ 4VC$PNQPOFOU &OUSZΛఏڙ͠ͳ͍ 4VC$PNQPOFOU 0QUJPOBMΛ༻ҙ͢Δ $PNQPOFOU 0QUJPOBMΛίϯετϥΫλ Ͱड͚औΔΫϥε "DUJWJUZ 0QUJPOBM5
03
0QUJPOBMΛίϯετϥΫλ Ͱड͚औΔΫϥε public class EntryManager { private final Entry mEntry;
@Inject public EntryManager(Optional<Entry> entryOptional) { mEntry = entryOptional.or(new Entry("default")); } public String getTitle() { return mEntry.title; } }
&OUSZΛఏڙ͠ͳ͍ $PNQPOFOU @Subcomponent public interface EmptyComponent { void inject(MainActivity activity);
@Subcomponent.Builder interface Builder { EmptyComponent build(); } }
&OUSZΛఏڙ͢Δ $PNQPOFOU @Subcomponent(modules = SavedEntryModule.class) public interface SavedEntryComponent { void
inject(MainActivity activity); @Subcomponent.Builder interface Builder { SavedEntryComponent build(); } }
&OUSZΛఏڙ͢Δ $PNQPOFOU @Module public class SavedEntryModule { @Provides Entry provideEntry()
{ return new Entry("saved"); } }
"DUJWJUZ public class MainActivity extends AppCompatActivity { @Inject EntryManager mEntryManager;
… DaggerMainComponent .create() .emptyComponent() .build() .inject(this); Log.e("title", mEntryManager.getTitle()); // default DaggerMainComponent .create() .savedEntryComponent() .build() .inject(this); Log.e("title", mEntryManager.getTitle()); // saved }
·ͱΊ w 0QUJPOBMͷΛޙͰղܾͰ͖Δ w 4VC$PNQPOFOUຖʹࠩҟΛग़ͤΔ w !*OKFDU͕ॻ͔ΕͨϑΟʔϧυɺίϯετϥΫ λͰͦͷ0QUJPOBMΛड͚औΕΔ w $PNQPOFOU͔ΒήολͰऔΔ͜ͱͰ
͖Δ
ࢀߟ w IUUQTHPPHMFHJUIVCJPEBHHFSVTFST HVJEF
͋Γ͕ͱ͏͍͟͝·ͨ͠