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
モダンフロントエンド 開発研修
recruitengineers
PRO
1
300
【CEDEC2026】専門性の高いデフォルメチームが挑んだ人材育成戦略 〜Cygames Academiaの企画から実施まで〜
cygames
PRO
0
230
AIエージェントの知識表現と推論に なぜグラフが使われるのか - 記号的AIの復権とニューラルAIとの統合
yohei1126
1
280
Retriever と Reranker、結局どうする?
kazuaki
2
660
Cursor Meetup Sapporo - Cursor物語 続編
cocacola917
0
120
Breaking the Seal: Static Deobfuscation of Compiled V8 JavaScript Bytecode Malware
hshrzd
0
460
侵入は突然に 〜 IoTマルウェアと悪用される家庭の機器 ~ / When Intrusion Strikes: IoT Malware and the Abuse of Home Devices
nttcom
0
1.4k
AIがAPIを書く時代に、私たちは何を設計すべきか
nagix
0
210
Redmine 7.0 新機能・機能強化解説(OSC2026京都ダイジェスト版)
vividtone
1
190
LangfuseによるLLMOps基盤の構築と活用事例
zozotech
PRO
1
270
Goでデータパイプラインを作ろう
sansantech
PRO
0
240
plamo-3-translateの開発
pfn
PRO
0
280
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
230
How to train your dragon (web standard)
notwaldorf
97
6.7k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.1k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
650
Faster Mobile Websites
deanohume
310
32k
Ruling the World: When Life Gets Gamed
codingconduct
0
290
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
The Curious Case for Waylosing
cassininazir
1
450
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
230
What's in a price? How to price your products and services
michaelherold
247
13k
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
͋Γ͕ͱ͏͍͟͝·ͨ͠