Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
DataArt & GDG - IT NonStop 2016 - Dagger 2
Search
Royce Mars
January 07, 2017
Programming
590
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
DataArt & GDG - IT NonStop 2016 - Dagger 2
Royce Mars
January 07, 2017
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.3k
GDG Ternopil - Mobile Applications Architecture
roycemars
1
1.8k
Ciklum & GDG Dnipro - Dagger 2
roycemars
1
1.5k
Architecture Components - IT Talk, Together With Google
roycemars
1
1.1k
Architecture Components - Build your app right way and enjoy IT! :) - GDG Kharkiv-Center
roycemars
1
590
Architecture Components - IT Step
roycemars
1
520
Quick Look at Design Patterns - GDG Dnipro-Art
roycemars
2
640
Jump into cross-platform development with Firebase - GDG Kharkiv-Center
roycemars
1
670
Ciklum & GDG Dnipro - Android N Security Overview
roycemars
1
370
Other Decks in Programming
See All in Programming
Groovy as a human and AI friendly programming language
paulk
0
160
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
250
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
2
240
dotNET_vulnclicker_intro.pdf
deka_morita
0
160
Spec-driven Development with AI
simas
PRO
0
2.2k
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
3
1.6k
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
4
3.5k
Next.js: The final boss of Web Performance
guaca
0
380
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
500
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
350
Seven New Principles of Software Engineering
yegor256
0
410
AI時代のIaC入門 〜なぜインフラをコードで管理したいのか?〜 / Introduction to IaC in the AI Era
akihisaikeda
6
1.3k
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
304
22k
The Curious Case for Waylosing
cassininazir
1
600
Discover your Explorer Soul
emna__ayadi
2
1.3k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.3k
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
770
Navigating Team Friction
lara
192
16k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
580
The Limits of Empathy - UXLibs8
cassininazir
2
750
Marketing to machines
jonoalderson
1
6k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
600
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
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