$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
DataArt & GDG - IT NonStop 2016 - Dagger 2
Search
Royce Mars
January 07, 2017
Programming
1
370
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
3k
GDG Ternopil - Mobile Applications Architecture
roycemars
1
1.6k
Ciklum & GDG Dnipro - Dagger 2
roycemars
1
1.3k
Architecture Components - IT Talk, Together With Google
roycemars
1
850
Architecture Components - Build your app right way and enjoy IT! :) - GDG Kharkiv-Center
roycemars
1
400
Architecture Components - IT Step
roycemars
1
410
Quick Look at Design Patterns - GDG Dnipro-Art
roycemars
2
430
Jump into cross-platform development with Firebase - GDG Kharkiv-Center
roycemars
1
430
Ciklum & GDG Dnipro - Android N Security Overview
roycemars
1
330
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
390
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
160
ローカルLLMを⽤いてコード補完を⾏う VSCode拡張機能を作ってみた
nearme_tech
PRO
0
180
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
400
Navigating Dependency Injection with Metro
l2hyunwoo
1
190
リリース時」テストから「デイリー実行」へ!開発マネージャが取り組んだ、レガシー自動テストのモダン化戦略
goataka
0
140
Grafana:建立系統全知視角的捷徑
blueswen
0
230
AtCoder Conference 2025
shindannin
0
670
Flutter On-device AI로 완성하는 오프라인 앱, 박제창 @DevFest INCHEON 2025
itsmedreamwalker
1
160
メルカリのリーダビリティチームが取り組む、AI時代のスケーラブルな品質文化
cloverrose
2
390
AI時代を生き抜く 新卒エンジニアの生きる道
coconala_engineer
1
440
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
220
Featured
See All Featured
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
580
How STYLIGHT went responsive
nonsquared
100
6k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
340
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
0
45
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
82
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
51
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.2k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.1k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
120
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