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
AI開発に用いられるHPC技術について
gpuunite_official
0
290
カーネルまで探検して理解するふたつの自動計装
sumiyae
0
320
AI for Science時代を切り開く、政府の次世代HPC戦略の展望
gpuunite_official
0
260
Rust×eBPFでEDRっぽいものをつくる
sunlife3
2
970
8bit CPU 2026
koba789
7
2.9k
AWSとGitHub Actionsの責任境界と 組織で安全に使用する取り組み
nealle
0
160
AI時代のアウトプット――変わったこと、変わらないこと / Devsumi 2026 Kansai #devsumi
jnchito
0
580
あなたの知らないバージョン命名規則
sat
PRO
2
760
英語が話せなくてもKubeConスタッフに参加した話
yusuke427
2
1.1k
Oracle MCP Servers Explained
thatjeffsmith
1
510
AIで変わるエンジニアの働き方(仮)
naoinaoi
0
550
【書籍出版記念】 10周回って、エージェント開発は RAGがすべてだった。〜RAGの歴史と開発現場で見えた実践知〜
akiratameto
20
7.6k
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6.1k
Design in an AI World
tapps
1
290
Are puppies a ranking factor?
jonoalderson
2
3.8k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
480
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
180
ラッコキーワード サービス紹介資料
rakko
1
4.5M
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Exploring anti-patterns in Rails
aemeredith
3
470
From π to Pie charts
rasagy
0
320
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
͋Γ͕ͱ͏͍͟͝·ͨ͠