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
32
30살에 구글이 인정한 개발자가 될 수 있었던 공부법
maryang
0
97
좋은 서비스를 만들기 위한 제품팀 문화 이해하기
maryang
0
47
사수 없는 주니어 개발자가 성장하는 방법
maryang
0
320
개발자가 성과를 증명하는 방법 | A/B테스트 기반 개발
maryang
0
110
개발자가 동료의 업무효율을 높이는 방법 | 슬랙봇 개념부터 개발까지
maryang
0
150
성장하는 스타트업이 사용하는 협업툴과 커뮤니케이션 방법
maryang
0
120
YOLO로 행복한 탑티어 개발자 되기
maryang
0
270
초 레거시 JSP 프로젝트를 최신 Next.js 13으로 마이그레이션 하기
maryang
0
98
Other Decks in Technology
See All in Technology
Mocking your codebase without cursing it
gaqzi
0
150
[TechNight #86] Oracle GoldenGate - 23ai 最新情報&プロジェクトからの学び
oracle4engineer
PRO
1
110
ObservabilityCON on the Road Tokyoの見どころ
hamadakoji
0
150
Zenn のウラガワ ~エンジニアのアウトプットを支える環境で Google Cloud が採用されているワケ~ #burikaigi #burikaigi_h
kongmingstrap
16
5k
生成AIを活用した機能を、顧客に提供するまでに乗り越えた『4つの壁』
toshiblues
1
180
Skip Skip Run Run Run ♫
temoki
0
350
プロダクト価値を引き上げる、「課題の再定義」という習慣
moeka__c
0
190
Grafanaのvariables機能について
tiina
0
120
インフラコストとセキュリティ課題解決のためのリアーキテクチャリング / srekaigi2025
hgsgtk
3
3.9k
あなたはJVMの気持ちを理解できるか?
skrb
5
1.9k
Oracle Cloud Infrastructure:2025年1月度サービス・アップデート
oracle4engineer
PRO
0
110
RevOpsへ至る道 データ活用による事業革新への挑戦 / path-to-revops
pei0804
2
660
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Thoughts on Productivity
jonyablonski
68
4.4k
Fireside Chat
paigeccino
34
3.2k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
370
Measuring & Analyzing Core Web Vitals
bluesmoon
6
220
Designing for humans not robots
tammielis
250
25k
Code Reviewing Like a Champion
maltzj
521
39k
The World Runs on Bad Software
bkeepers
PRO
66
11k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
The Cult of Friendly URLs
andyhume
78
6.2k
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