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 마량
30살에 구글이 인정한 개발자가 될 수 있었던 공부법
maryang
0
55
좋은 서비스를 만들기 위한 제품팀 문화 이해하기
maryang
0
41
사수 없는 주니어 개발자가 성장하는 방법
maryang
0
280
개발자가 성과를 증명하는 방법 | A/B테스트 기반 개발
maryang
0
87
개발자가 동료의 업무효율을 높이는 방법 | 슬랙봇 개념부터 개발까지
maryang
0
110
성장하는 스타트업이 사용하는 협업툴과 커뮤니케이션 방법
maryang
0
93
YOLO로 행복한 탑티어 개발자 되기
maryang
0
220
초 레거시 JSP 프로젝트를 최신 Next.js 13으로 마이그레이션 하기
maryang
0
70
Firebase에서 최신 Next.js를 사용하여 웹사이트 운영하기
maryang
0
250
Other Decks in Technology
See All in Technology
AIチャットボット開発への生成AI活用
ryomrt
0
160
Intuneお役立ちツールのご紹介
sukank
3
790
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
150
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.1k
Microsoft Intune アプリのトラブルシューティング
sophiakunii
1
470
Microsoft MVPになる前、なってから/Fukuoka_Tech_Women_Community_1_baba
nina01
0
190
Lambdaと地方とコミュニティ
miu_crescent
2
350
Windows Autopilot Deployment by OSD Guy
tamaiyutaro
0
420
Can We Measure Developer Productivity?
ewolff
1
130
データの信頼性を支える仕組みと技術
chanyou0311
6
1.7k
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
3
1.3k
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
0
900
Featured
See All Featured
Bash Introduction
62gerente
608
210k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Docker and Python
trallard
40
3.1k
Documentation Writing (for coders)
carmenintech
65
4.4k
It's Worth the Effort
3n
183
27k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Side Projects
sachag
452
42k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Thoughts on Productivity
jonyablonski
67
4.3k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
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