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
500
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.1k
GDG Ternopil - Mobile Applications Architecture
roycemars
1
1.7k
Ciklum & GDG Dnipro - Dagger 2
roycemars
1
1.4k
Architecture Components - IT Talk, Together With Google
roycemars
1
970
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
550
Ciklum & GDG Dnipro - Android N Security Overview
roycemars
1
340
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
270
Claude Codeセッション現状確認 2026福岡 / fukuoka-aicoding-00-beacon
monochromegane
3
320
株式会社 Sun terras カンパニーデック
sunterras
0
1.9k
Package Management Learnings from Homebrew
mikemcquaid
0
280
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
440
モジュラモノリスにおける境界をGoのinternalパッケージで守る
magavel
0
3k
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
130
文字コードの話
qnighy
41
16k
JPUG勉強会 OSSデータベースの内部構造を理解しよう
oga5
2
220
日本だけで解禁されているアプリ起動の方法
ryunakayama
0
360
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
310
CopilotKit + AG-UIを学ぶ
nearme_tech
PRO
1
110
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
698
190k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
370
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.3k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
66
Abbi's Birthday
coloredviolet
2
5k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.9k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
130
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
460
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.1k
The agentic SEO stack - context over prompts
schlessera
0
670
Facilitating Awesome Meetings
lara
57
6.8k
How STYLIGHT went responsive
nonsquared
100
6k
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