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 라이트하게 훑기
Search
Seungmin 마량
February 02, 2018
Technology
1
1.4k
Dagger2 라이트하게 훑기
2018년 2월 2일 GDG 안드로이드 라이트닝 토크에서 발표한 자료입니다. Dagger2를 배우기 위한 기본 이론부터 Dagger2 개념, 사용방법까지 라이트하게 다루었습니다.
Seungmin 마량
February 02, 2018
Tweet
Share
More Decks by Seungmin 마량
See All by Seungmin 마량
대규모 트래픽을 처리하는 프론트 개발자의 전략
maryang
0
130
프론트엔드 개발자가 실제로 하는 일과 취업 준비 팁
maryang
0
28
나는 좋은 상사일까? 팀장은 꼭 봐야 할 리더십 공식
maryang
0
39
미국 교환학생 가서 무료 홈스테이 살면서 인턴 취업하기
maryang
0
120
글로벌 기업은 홈페이지에서 영어 번역을 어떻게 제공할까?
maryang
0
66
30살에 구글이 인정한 개발자가 될 수 있었던 공부법
maryang
0
170
좋은 서비스를 만들기 위한 제품팀 문화 이해하기
maryang
0
69
사수 없는 주니어 개발자가 성장하는 방법
maryang
0
380
개발자가 성과를 증명하는 방법 | A/B테스트 기반 개발
maryang
0
140
Other Decks in Technology
See All in Technology
メルカリIBISの紹介
0gm
0
780
Webアプリケーションにオブザーバビリティを実装するRust入門ガイド
nwiizo
7
900
OCI Oracle Database Services新機能アップデート(2025/06-2025/08)
oracle4engineer
PRO
0
180
KotlinConf 2025_イベントレポート
sony
1
140
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
8.8k
AIがコード書きすぎ問題にはAIで立ち向かえ
jyoshise
3
860
ブロックテーマ時代における、テーマの CSS について考える Toro_Unit / 2025.09.13 @ Shinshu WordPress Meetup
torounit
0
130
共有と分離 - Compose Multiplatform "本番導入" の設計指針
error96num
2
1.2k
「どこから読む?」コードとカルチャーに最速で馴染むための実践ガイド
zozotech
PRO
0
570
EncryptedSharedPreferences が deprecated になっちゃった!どうしよう! / Oh no! EncryptedSharedPreferences has been deprecated! What should I do?
yanzm
0
500
Snowflake×dbtを用いたテレシーのデータ基盤のこれまでとこれから
sagara
0
140
測りにくい成果を測る — BtoB SaaSにおける効果検証への挑戦 / Shirokane Kougyou vol 20
sansan_randd
1
130
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
The Language of Interfaces
destraynor
161
25k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Six Lessons from altMBA
skipperchong
28
4k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
For a Future-Friendly Web
brad_frost
180
9.9k
The Pragmatic Product Professional
lauravandoore
36
6.9k
Reflections from 52 weeks, 52 projects
jeffersonlam
352
21k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
188
55k
Embracing the Ebb and Flow
colly
87
4.8k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Transcript
थ Drama&Company Seungmin Lee Dagger2 ۄೞѱ വӝ GDG উ٘۽٘ ۄ
ష
1. Daggerܳ ਤೠ ӝࠄѐ֛ ೧ೞӝ 2. Dagger ѐ֛ ೧ೞӝ 3.
Dagger ࢎਊೞӝ 4. ݃ޖܻ ݾର
Daggerܳ ਤೠ ӝࠄѐ֛ ೧ೞӝ Ƃ
DI Framework Daggerח ޖੌө?
Dependency Injection (ઓࢿ ੑ) DIח ޖੌө?
ઓࢿ ੑ ޖੌө? A classо B classܳ ઓೡ ٸ B
Object ࢤࢿਸ Aীࢲ ೞ ঋҊ ৻ࠗীࢲ ࢤࢿೞৈ ֈѹח Ѫ
ઓࢿ ੑ ޖੌө? Aо B,Cী ઓ Aীࢲ B,Cܳ ࢤࢿ
ઓࢿ ੑ ޖੌө? Aо B,Cী ઓ Aীࢲ B,Cܳ ࢤࢿ ৻ࠗীࢲ
B,Cܳ ࢤࢿೞৈ ֈӣ ઓࢿ ੑ!
DI Frameworkо যڌѱ ઓࢿਸ ੑೡө?
DI Frameworkо যڌѱ ઓࢿਸ ੑೡө? ஶపցח Spring ਊয ೞ݅ ߑध
ܳ ࡺ, ਗܻо э Daggerীࢲח Component৬ Module
IoCח ޖੌө? Inversion of Control (ઁয ) DIח IoC ҳഅߑߨ
ೞա
DIח ৵ ਃೡө? ёࢤࢿਸ ৻ࠗী ਤೣਵ۽ॄ Constructor Parameter ١ ࠁੌ۞
ۨ ٘ܳ ઁѢ
ઓࢿ ٘ܳ ݶ ޖ જо? ࠁੌ۞ ۨ ٘ܳ ઁѢೣਵ۽ॄ 1.
ӈଳ ঋ.
ઓࢿ ٘ܳ ݶ ޖ જо? ࠁੌ۞ ۨ ٘ܳ ઁѢೣਵ۽ॄ 1.
ӈଳ ঋ. 2. ٘ܳ ਬোೞѱ ߸҃ೡ ࣻ .
Dagger ѐ֛ ೧ೞӝ Ƃ
Daggerܳ ܖח ਃ ѐ֛ٜ 1.Inject 2.Component 3.Subcomponent 4.Module 5.Scope
Inject Componentীѱ ઓࢿ ੑਸ ਃ
Component Module۽ࠗఠ ࢤࢿػ ઓࢿ ёܳ ੑ
Subcomponent ࠗݽ Component Inner Component Subcomponent Module۽ ੑ पಁೞݶ, ࠗݽ
Component Moduleਸ Ѩ࢝ೠ
Module ઓࢿ ёܳ ࢤࢿ
Scope ࢤࢿػ ё Lifecycle ߧਤ PerActivity PerFragment …
Daggerо ઓࢿਸ ੑೞח Flow @Inject Subcomponent Module Scopeী ਵݶ return
হਵݶ ࢤࢿ
Daggerо ઓࢿਸ ੑೞח Flow @Inject Scopeী ਵݶ return হਵݶ ࢤࢿ
Subcomponent Module Scopeী ਵݶ return হਵݶ ࢤࢿ Module Subcomponent Moduleীࢲ ݏח ఋੑਸ ޅਵݶ ࢚ਤ Component
Daggerо ઓࢿਸ ੑೞח Flow @Inject
Dagger ࢎਊೞӝ Ƃ
@Singleton @Component(modules = {AndroidSupportInjectionModule.class, ActivityBindingModule.class, ApplicationModule.class}) public interface AppComponent extends
AndroidInjector<BaseApplication> { @Component.Builder interface Builder { @BindsInstance AppComponent.Builder application(Application application); AppComponent build(); } } Application Component
@Module public class ApplicationModule { @Provides Context providesContext(Application application){ return
application; } } Context ఋੑ ઓࢿ ёܳ ࢤࢿೠ Application Module
public class BaseApplication extends DaggerApplication { @Override protected AndroidInjector<? extends
DaggerApplication> applicationInjector() { return DaggerAppComponent.builder().application(this).build(); } } BaseApplication Component.inject() ೧ષ
@Module public abstract class ActivityBindingModule { @ActivityScoped @ContributesAndroidInjector(modules = TasksModule.class)
abstract TasksActivity tasksActivity(); @ActivityScoped @ContributesAndroidInjector(modules = TaskDetailPresenterModule.class) abstract TaskDetailActivity taskDetailActivity(); } ActivitySubcomponent ࢤࢿ
@Module public abstract class TasksModule { @FragmentScoped @ContributesAndroidInjector abstract TasksFragment
tasksFragment(); @ActivityScoped @Provides static TasksPresenter taskPresenter(){ return new TasksPresenter(); } } ActivitySubcomponent Module TasksPresenter ఋੑ ઓࢿ ёܳ ࢤࢿೠ
public class TasksActivity extends DaggerAppCompatActivity { @Inject TasksPresenter mTasksPresenter; @Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tasks_act); } } TasksActivity Component.inject() ೧ષ ઓࢿ ੑ ਃ
@Module public abstract class TasksModule { @FragmentScoped @ContributesAndroidInjector abstract TasksFragment
tasksFragment(); @ActivityScoped @Provides static TasksPresenter taskPresenter(){ return new TasksPresenter(); } } FragmentSubcomponent ࢤࢿ
@ActivityScoped public class TasksFragment extends DaggerFragment { @Inject TasksContract.Presenter mPresenter;
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mListAdapter = new TasksAdapter(new ArrayList<Task>(0), mItemListener); } } TasksFragment Component.inject() ೧ષ ઓࢿ ੑ ਃ
݃ޖܻ Ƃ
Inject ࢤࢿ @Injectо ઓࢿ ਃ ৻ী ёࢤࢿীب ࢎਊػ. పझ పझ
ё, पઁ ёܳ औѱ աׂ ࣻ . য়ט ޅ ࠁৈ٘ܽ Dagger Dagger2 ҕध ࢎ: https://google.github.io/dagger/ Dagger2ܳ ࢎਊೠ Google Architecture Sample: https://github.com/googlesamples/android-architecture/tree/todo-mvp-dagger/
Dagger ః ஶࣆ Daggerח Ӓې. Subcomponent, Component, Inject ࢤࢿ ࣽਵ۽
Ѩ࢝ೞৈ ઓࢿਸ ੑೠ.
ण࠺ਊ ֫݅ ఁפ. Ӓې ਗܻܳ ݺबೠݶ য۵ ঋইਃ. ನӝೞ݈Ҋ
ୌୌ ਊ೧ࠇद.
٘ۄ݃ঙஹಌפীࢲ ҳੋ೧ਃ ӝദ ٣ց ݃ா HR Android iOS Web Server
Data Engineering ࠁࠁউ goo.gl/UDcg97
थ Drama&Company Seungmin Lee хࢎפ Q&A