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
DataArt & GDG - IT NonStop 2016 - Dagger 2
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Royce Mars
January 07, 2017
Programming
1
510
DataArt & GDG - IT NonStop 2016 - Dagger 2
Royce Mars
January 07, 2017
Tweet
Share
More Decks by Royce Mars
See All by Royce Mars
GDG Ukraine - Post I/O Tour 2018 - Kyiv, Dnipro, Kharkiv, Cherkasy, Kremenchuk, Poltava, Kropyvnytskyy - Google Cloud & Firebase
roycemars
1
3.2k
GDG Ternopil - Mobile Applications Architecture
roycemars
1
1.8k
Ciklum & GDG Dnipro - Dagger 2
roycemars
1
1.4k
Architecture Components - IT Talk, Together With Google
roycemars
1
980
Architecture Components - Build your app right way and enjoy IT! :) - GDG Kharkiv-Center
roycemars
1
510
Architecture Components - IT Step
roycemars
1
420
Quick Look at Design Patterns - GDG Dnipro-Art
roycemars
2
530
Jump into cross-platform development with Firebase - GDG Kharkiv-Center
roycemars
1
560
Ciklum & GDG Dnipro - Android N Security Overview
roycemars
1
350
Other Decks in Programming
See All in Programming
Go Conference mini in Sendai 2026 : Goに新機能を提案し実装されるまでのフロー徹底解説
yamatoya
0
620
「接続」—パフォーマンスチューニングの最後の一手 〜点と点を結ぶ、その一瞬のために〜
kentaroutakeda
3
1.2k
Vuetify 3 → 4 何が変わった?差分と移行ポイント10分まとめ
koukimiura
0
160
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
710
CSC307 Lecture 14
javiergs
PRO
0
480
Claude Code Skill入門
mayahoney
0
410
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
800
AHC061解説
shun_pi
0
400
仕様漏れ実装漏れをなくすトレーサビリティAI基盤のご紹介
orgachem
PRO
7
2.5k
API Platformを活用したPHPによる本格的なWeb API開発 / api-platform-book-intro
ttskch
1
150
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
13
8.2k
Docコメントで始める簡単ガードレール
keisukeikeda
1
130
Featured
See All Featured
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.1k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
110
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
What does AI have to do with Human Rights?
axbom
PRO
1
2k
Un-Boring Meetings
codingconduct
0
230
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Why Our Code Smells
bkeepers
PRO
340
58k
A Modern Web Designer's Workflow
chriscoyier
698
190k
4 Signs Your Business is Dying
shpigford
187
22k
How to Think Like a Performance Engineer
csswizardry
28
2.5k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
290
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Transcript
Dagger 2 Лечим зависимости по методике :) Докладчик: Constantine Mars
Senior Developer @ DataArt, Co-Organizer @ GDG Dnipro
Dependency Injection Что, зачем, и когда это нужно
Создание классов порождает... • Композиция - не наследование • Ссылки
не будут пустовать
Возможность создавать объекты...
Создавать разные объекты...
Комбинировать объекты (“композиция” объектов)...
Использовать наследование и разнообразить композицию...
И… Зависимости Car depends on Engine. Engines may vary. We’ll
probably need different engines for testing and production
Dagger and JSR-330 Аннотация @Inject
немного еще НЕ истории • Dagger 2 - Google, Greg
Kick • Dagger - Square, Jake Wharthon • Guice - Google, Jesse Wilson
Inversion of Control Invert your dependencies
Reflection vs Compile time • Dagger 2 vs Dagger 1
JSR-330
Puttin’ there piece of magic...
Обратите внимание на конструктор по умолчанию
А вот конструктор с параметрами - хорошее место для модификаций...
И все же, как это заставить работать?
Структура инжекции Dagger 2.0 Модули, Компоненты
Компоненты и модули Pic. author - Miroslaw Stanek from Azimo
http://frogermcs.github.io/dagger-graph-creation-performance/
Модуль… next slide, please
Модуль - коллекция генераторов
Компонент - хост для модулей, инжектор для классов, корень дерева
зависимостей
То же самое, только с красными стрелочками :]
Инициализация компонента generated code used
Inject This! :) Puttin’ magic will work only after injection…
;)
Inject This! :)
Custom Scopes и эффективное управление памятью
Жизненный цикл объектов Pic. author - Miroslaw Stanek from Azimo
http://frogermcs.github.io/dagger-graph-creation-performance/
И еще раз та же матрешка Компонент имеет область жизни
(scope) Pic. author - Miroslaw Stanek from Azimo http://frogermcs.github.io/dagger-graph-creation-performance/
This mysterious ‘plus’...
Объявление суп-компонента
Но ведь там был модуль! =)
Добавление субкомпонента к корню дерева зависимостей
Как управлять временем жизни субкомпонентов? Pic. author - Miroslaw Stanek
from Azimo http://frogermcs.github.io/dagger-graph-creation-performance/
Аннотация @Scope
@ActivityScope
@ActivityScope
@UserScope
@UserScope
@UserScope
Напоследок… Что инжектить? • Модули демо-данных • Презентеры • Синглетоны
• Тестовые реализации классов • ...Все остальное что инстанцируется и создает зависимости :)
Home readings Sample code: https://github.com/c-mars/Dagger2Scopes.git • Fernando Cejas “Tasting Dagger
2 on Android”: http://fernandocejas.com/2015/04/11/tasting-dagger-2-on-android/ • • Miroslaw Stanek “Dagger2 - graph creation performance: http://frogermcs.github.io/dagger-graph-creation-performance/ • • Dagger2 official page: http://google.github.io/dagger/
Смысл кода Как мы организовали быструю Agile-разработку с использованием Mock-модулей,
и в итоге обгонали сервер-сайд
Всем спасибо! Contact me:
[email protected]
+ConstantineMars