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
69
프론트엔드 개발자가 실제로 하는 일과 취업 준비 팁
maryang
0
14
나는 좋은 상사일까? 팀장은 꼭 봐야 할 리더십 공식
maryang
0
28
미국 교환학생 가서 무료 홈스테이 살면서 인턴 취업하기
maryang
0
110
글로벌 기업은 홈페이지에서 영어 번역을 어떻게 제공할까?
maryang
0
60
30살에 구글이 인정한 개발자가 될 수 있었던 공부법
maryang
0
150
좋은 서비스를 만들기 위한 제품팀 문화 이해하기
maryang
0
63
사수 없는 주니어 개발자가 성장하는 방법
maryang
0
370
개발자가 성과를 증명하는 방법 | A/B테스트 기반 개발
maryang
0
130
Other Decks in Technology
See All in Technology
メモ整理が苦手な者による頑張らないObsidian活用術
optim
0
120
AI Ready API ─ AI時代に求められるAPI設計とは?/ AI-Ready API - Designing MCP and APIs in the AI Era
yokawasa
21
5.8k
MCPと認可まわりの話 / mcp_and_authorization
convto
1
150
SAE J1939シミュレーション環境構築
daikiokazaki
0
150
Webの技術とガジェットで那須の子ども達にワクワクを! / IoTLT_20250720
you
PRO
0
120
スプリントゴール未達症候群に送る処方箋
kakehashi
PRO
1
200
AIコードアシスタントとiOS開発
jollyjoester
1
230
なぜAI時代に 「イベント」を中心に考えるのか? / Why focus on "events" in the age of AI?
ytake
2
590
AI駆動開発 with MixLeap Study【大阪支部 #3】
lycorptech_jp
PRO
0
210
20250718_ITSurf_“Bet AI”を支える文化とコストマネジメント
helosshi
1
210
Expertise as a Service via MCP
yodakeisuke
1
150
増え続ける脆弱性に立ち向かう: 事前対策と優先度づけによる 持続可能な脆弱性管理 / Confronting the Rise of Vulnerabilities: Sustainable Management Through Proactive Measures and Prioritization
nttcom
1
170
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1031
460k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
50
5.5k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
47
9.6k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
370
Side Projects
sachag
455
43k
BBQ
matthewcrist
89
9.7k
Six Lessons from altMBA
skipperchong
28
3.9k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Making the Leap to Tech Lead
cromwellryan
134
9.4k
A Modern Web Designer's Workflow
chriscoyier
695
190k
Fireside Chat
paigeccino
37
3.5k
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