Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Square/Dagger, Google/Dagger
Search
Daichi Furiya (Wasabeef)
September 24, 2014
Programming
1.6k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Square/Dagger, Google/Dagger
Daichi Furiya (Wasabeef)
September 24, 2014
More Decks by Daichi Furiya (Wasabeef)
See All by Daichi Furiya (Wasabeef)
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
6
2.9k
About Flutter Architecture
wasabeef
1
330
2023 Flutter/Dart Summary
wasabeef
0
140
I/O Extended 2023 - Dart と Flutter の新機能
wasabeef
0
250
I/O Extended 2023 - Flutter 活用事例
wasabeef
10
3.1k
What it Takes to be a Flutter Developer
wasabeef
0
270
FlutterKaigi 2022 Keynote
wasabeef
1
760
Flutter Hooks を使ったアプリ開発 / App Development with the Flutter Hooks
wasabeef
2
1.5k
Flutter 2021 の振り返りと今後のアプリ開発に向けて / Looking back on Flutter 2021 and for future app development.
wasabeef
4
2.3k
Other Decks in Programming
See All in Programming
Security issues being discussed on Web Platforms
petamoriken
0
890
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
1
310
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
800
アクセシビリティから考える情報設計
high_g_engineer
0
370
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
150
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
270
高専キャリア LT 発表内容
crysta1221
6
5.7k
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
160
AIエージェント時代のコードレビューを設計する
nogu66
6
2.7k
Webの地図
yosuke_furukawa
PRO
6
4.4k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
340
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
450
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
247
13k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
270
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
330
Believing is Seeing
oripsolob
1
220
The Art of Programming - Codeland 2020
erikaheidi
57
14k
How to Talk to Developers About Accessibility
jct
2
550
How to Think Like a Performance Engineer
csswizardry
28
2.8k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
930
The Spectacular Lies of Maps
axbom
PRO
1
990
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
500
Transcript
Android Square/Dagger potatotips #9 CyberAgent, Inc. ߱ େ
About Me Wasabeef (D.Furiya) @wasabeef_jp wasabeef http://wasabeef.jp
Dagger (ObjectGraph) ɾίϯύΠϧ࣌ݕূɿϞδϡʔϧͱೖΛݕূ͢Δ ɹΞϊςʔγϣϯϓϩηοα ! ɾ࣮ߦ࣌ʹɺϦϑϨΫγϣϯΛར༻͠ͳ͍ ! ɾϝϞϦͷӨڹۃΘ͔ͣʹ͢Δ ! ɾViewͷInjectग़དྷͳ͍
Dagger ͷߏཁૉ
@Module + @Provides ґଘؔΛఏڙ͢ΔͨΊͷΈɾઃఆ
ObjectGraph ґଘؔཧͱΠϯδΣΫλ
@Inject ґଘؔΛཁٻ͢ΔͨΊͷΈ
@Module + @Provides ͷఆٛ
! public class ApiModule { ! public RestAdapter provideRestAdapter(OkHttpClient client)
{ return new RestAdapter.Builder() .setEndpoint(“http://wasabeef.jp”) .setClient(new OkClient(client)) .build(); } ! ! public OkHttpClient provideOkHttpClient() { return new OkHttpClient(); } }
@Module( injects = ExampleActivity.java ) public class ApiModule { !
public RestAdapter provideRestAdapter(OkHttpClient client) { return new RestAdapter.Builder() .setEndpoint(“http://wasabeef.jp”) .setClient(new OkClient(client)) .build(); } ! ! public OkHttpClient provideOkHttpClient() { return new OkHttpClient(); } }
@Module( injects = ExampleActivity.java ) public class ApiModule { @Provides
public RestAdapter provideRestAdapter(OkHttpClient client) { return new RestAdapter.Builder() .setEndpoint(“http://wasabeef.jp”) .setClient(new OkClient(client)) .build(); } ! @Provides public OkHttpClient provideOkHttpClient() { return new OkHttpClient(); } }
@Module( injects = ExampleActivity.java ) public class ApiModule { @Provides
@Singleton public RestAdapter provideRestAdapter(OkHttpClient client) { return new RestAdapter.Builder() .setEndpoint(“http://wasabeef.jp”) .setClient(new OkClient(client)) .build(); } ! @Provides @Singleton public OkHttpClient provideOkHttpClient() { return new OkHttpClient(); } }
ObjectGraph + @Inject ͷఆٛ
public class ExampleActivity extends Activity { ! ! RestAdapter mRestAdapter;
! @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ! mRestAdapter = new RestAdapter.Builder() .setEndpoint(“http://wasabeef.jp”) .setClient(new OkClient(new OkHttpClient())) .build(); } }
public class ExampleActivity extends Activity { private ObjectGraph mObjectGraph; !
RestAdapter mRestAdapter; ! @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ! mRestAdapter = new RestAdapter.Builder() .setEndpoint(“http://wasabeef.jp”) .setClient(new OkClient(new OkHttpClient())) .build(); } }
public class ExampleActivity extends Activity { private ObjectGraph mObjectGraph; !
RestAdapter mRestAdapter; ! @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ! mObjectGraph = ObjectGraph.create(new ApiModule()); mObjectGraph.inject(this); ! ! } }
public class ExampleActivity extends Activity { private ObjectGraph mObjectGraph; !
@Inject RestAdapter mRestAdapter; ! @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ! mObjectGraph = ObjectGraph.create(new ApiModule()); mObjectGraph.inject(this); ! ! } }
ObjectGraph.plus
public class SignUpActivity extends Activity { private ObjectGraph mObjectGraph; !
@Inject RestAdapter mRestAdapter; ! @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ! ExampleApp app = (ExampleApp) getApplication(); mObjectGraph = app.getObjectGraph(); mObjectGraph.plus(new SignUpModule()); mObjectGraph.inject(this); } }
Google/Dagger
Square/Daggerͱͷҧ͍ ɾτϨʔαϏϦςΟ “Open Declaration”“Find usages”ͳͲͰɺݺͼग़͠ݩͷτϨʔε͕ग़དྷΔ ! ɾ໌֬ͳAPI “@Module”ΛΘ͔Γ͘͢͠ɺ”@Component”, “@Subcomponent”ͷՃ !
ɾύϑΥʔϚϯε্ ReflectionΘͳ͍ ࣗಈੜ͞ΕΔίʔυΛखॻ͖ͷΑ͏ʹͳίʔυ࣭ʹ͚ۙͮΔ
Google/Dagger ! ։ൃதͳͷͰ ػೳFix͏গ͔͔͠Γͦ͏ɻ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠