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
もう一度考える SRE チームの作り方・育て方 / Rethinking SRE #1: Building and Growing SRE Teams
rrreeeyyy
6
1k
Software Supply Chain Attackからクラウド環境を守るためにできること
lhazy
2
200
SnowflakeCoCoでデータエンジニアリング!
foursue
0
180
侵入は突然に 〜 IoTマルウェアと悪用される家庭の機器 ~ / When Intrusion Strikes: IoT Malware and the Abuse of Home Devices
nttcom
0
1.5k
AIコーディングの次。コードレビューと理解負荷を解消して組織の開発生産性を高める
moongift
PRO
2
2.2k
新しい SLO が良い感じにハマっている話
z63d
5
2.1k
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
19k
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
53k
ボトムアップ文化が強い組織で セキュリティをどう根付かせていくかの現在進行形の話 / Making Security Stick in a Bottom-Up Organization
yamaguchitk333
0
200
ガバメントクラウドでのランサムウェア対策
techniczna
2
940
サイバー捜査員研修(後半)
nomizone
1
790
初めてのGitHub Actions / GitHub Actions at First
tooppoo
0
150
Featured
See All Featured
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
440
WCS-LA-2024
lcolladotor
0
790
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
650
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
BBQ
matthewcrist
89
10k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
Mind Mapping
helmedeiros
PRO
1
300
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
480
Producing Creativity
orderedlist
PRO
348
40k
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
͋Γ͕ͱ͏͍͟͝·ͨ͠