The document compares Dagger and Koin dependency injection frameworks for Android. It discusses that Dagger uses compile-time code generation while Koin is runtime without code generation. It provides examples of implementing dependency injection with field injection, modules, and scoping for both frameworks. It also covers testing dependency injection with Koin. In summary, the document notes that Dagger scales better but has slower build times while Koin is simpler to use but errors occur at runtime.
This document provides step by step instructions on how to achieve dependency injection using dagger 2. The code is written in java. The code content is courtesy of Coding In Flow - You can check out this channel for in-depth explanation. https://www.youtube.com/watch?v=ZZ_qek0hGkM&list=PLrnPJCHvNZuA2ioi4soDZKz8euUQnJW65
React ES5 to ES6 | React ES5 vs ES6 | React Tutorial for Beginners | React on...Edureka!
( ReactJS Training - https://www.edureka.co/reactjs-redux-... )
This Edureka React tutorial on ES5 to ES6 Refactoring will help you in understanding the current syntax being used in React and what new features you can use in the upgraded version. This video helps you to learn following topics:
1. Introduction to React Components
2. Component structure in ES5
3. ES5 with pros, cons and code example
4. Benefits to ES6
5. ES6 restructuring of code example
6. Building Tic tac Toe game in React using ES6
Slides for our (John Rodriguez and myself) talk at Droidcon SF: http://sf.droidcon.com/schedule
For the past 3 years, Square Register Android has leveraged Dagger † to wire up Java objects. However, the app scope hierarchy and complexity increased and we started having bugs and crashes related to scoping errors. This talk will show how to structure an app around Dagger2 ‡ and present a strategy for incrementally migrating from Dagger1 to Dagger2.
This document provides step by step instructions on how to achieve dependency injection using dagger 2. The code is written in java. The code content is courtesy of Coding In Flow - You can check out this channel for in-depth explanation. https://www.youtube.com/watch?v=ZZ_qek0hGkM&list=PLrnPJCHvNZuA2ioi4soDZKz8euUQnJW65
React ES5 to ES6 | React ES5 vs ES6 | React Tutorial for Beginners | React on...Edureka!
( ReactJS Training - https://www.edureka.co/reactjs-redux-... )
This Edureka React tutorial on ES5 to ES6 Refactoring will help you in understanding the current syntax being used in React and what new features you can use in the upgraded version. This video helps you to learn following topics:
1. Introduction to React Components
2. Component structure in ES5
3. ES5 with pros, cons and code example
4. Benefits to ES6
5. ES6 restructuring of code example
6. Building Tic tac Toe game in React using ES6
Slides for our (John Rodriguez and myself) talk at Droidcon SF: http://sf.droidcon.com/schedule
For the past 3 years, Square Register Android has leveraged Dagger † to wire up Java objects. However, the app scope hierarchy and complexity increased and we started having bugs and crashes related to scoping errors. This talk will show how to structure an app around Dagger2 ‡ and present a strategy for incrementally migrating from Dagger1 to Dagger2.
Slides of the university I gave at Devoxx Belgium with Antonio Goncalves on CDI, Java EE and JBoss Forge.
Abstract:
-------
During this 3 hours university, you will learn some CDI basis, and will quickly dive into more advance CDI features (such as extension). Using JBoss Forge we will quickly generate a Java EE 7 web application, and then, following business requirements, we will add CDI functionalities.
This university talk will be a mixture of code and slides, focusing on CDI and Java EE 7.
--------
Video of the university is available on YouTube: http://youtu.be/LYKMaj4XKvg
Code and Slides on GitHub: https://github.com/antoinesd/cdi-forge-uni/tree/DevoxxBe2015
Probabilmente il framework javascript più atteso di sempre, evoluzione di uno dei framework più longevi ed usati nello sviluppo front end. Si vedranno alcune delle novità introdotte e delle scelte radicali fatte da Google per la nuova versione di Angular
As your app code gets larger and more complex, it makes sense to break your project out into smaller reusable components. But what’s the best way to do this? How can you clearly version your internal libraries? What kind of setup and maintenance can you expect? How much could it slow down development time?
In this talk we’ll dive into the various ways you can manage internal library dependencies. We’ll chat about the current state of Android dependency management, Gradle multi-project builds, Git submodules, and creating a private maven repository in Artifactory. The speaker will share real-world examples, and the pros and cons of each approach.
This presentation explains the benefits of Dagger 2, a Dependency Injections framework. It will be useful for Android developers.
The author of the presentation is Anton Minashkin (Android Developer, GlobalLogic); he delivered it at IT Saturday on June 6, 2015 in Kyiv.
Антон Минашкин
Android разработчик с 5-летним стажем. Сейчас занимает должность Android Developer в GlobalLogic . Выступал на UA Mobile'14 , конференции "IT- ПЕРСПЕКТИВА" , Kyiv Android gathering , Android Dev Club и др . Cоорганизатор сообществ GDG Kremenchuk и IT Kremenchuk .
Until now camera development has been very painful within android development. Although Camera2 API solved some of the problems in the original Camera API, however there were still lots of difficulties existed to write camera features. With the recent launch of JetPack CameraX support library, it aims to make camera app development easier by providing consistency and easy-to-use API that works on devices running Lollipop API-21 or above. In this talk, we will review main uses cases of CameraX Api which are preview, image analysis and image capture. We will also explore device-specific extensions such as portrait, HDR, night and beauty mode
Modularizing a project is never easy, a lot of files to move and the dependencies between them is not always what we expect. Then the Dagger configuration used in a single module project often doesn't scale well to a multi module project. Hilt is opinionated about the configuration to use (we don't need to argue anymore about using component dependencies or subcomponents!) and this configuration works perfectly even in a multi module project. In this talk we'll see first an introduction to Hilt and a comparison with Dagger to understand why it's easier to configure. Then we'll see how to leverage it in a multi module project (both in a standard layered architecture and in a Clean Architecture that uses the Dependency Inversion) to improve build speed and code testability. Spoiler alert: using sample apps that include a single feature in the app helps a lot!
Improving app performance with Kotlin CoroutinesHassan Abid
Coroutines were added to Kotlin in version 1.3 and since then they became a popular choice for android developers to simplify code that executes asynchronously. Coroutines are lightweight threads and on android they help to solve the primary problems of long running tasks that might block the main thread and also providing safety for offloading network or disk operations from the main thread. This talk covers how coroutines work with architecture components
Documentation: https://izumi.7mind.io/latest/release/doc/distage/
Github: https://github.com/pshirshov/izumi-r2
Pavel Shirshov - DIStage: purely functional programming without sacrificing modularity with modern dependency injection for Scala
- Modularity and its importance
- DI-like mechanisms and their issues in Scala
- Why people think that "DI doesn't compose with functional programming", and why that's not true
- Designing a staged DI, for wiring at runtime, at compile-time, or mixed
- Staging programs for reliability, power and performance
- The pains of supporting rich Scala types (incl. How to emulate kind-polymorphism in Scala 2)
- Garbage collection in DI for better tests and deployments
Pavel's bio: Language-agnostic software engineer, coding for 18 years,
10 years of hands-on commercial engineering experience.
Led a cluster orchestration team at Yandex, "the Russian Google"; implemented an internal orchestration solution, "ISS" (Scala/Java/C++), managing 50K+ physical hosts across 6 datacenters.
Today, Pavel owns Irish R&D company Septimal Mind.
Building Modern Apps using Android Architecture ComponentsHassan Abid
Android architecture components are part of Android Jetpack. They are a collection of libraries that help you design robust, testable, and maintainable apps. In this talk, We will cover LiveData, ViewModel, Room and lifecycle components. We will go through practical code example to understand modern android app architecture especially MVVM architecture.
Slides of the university I gave at Devoxx Belgium with Antonio Goncalves on CDI, Java EE and JBoss Forge.
Abstract:
-------
During this 3 hours university, you will learn some CDI basis, and will quickly dive into more advance CDI features (such as extension). Using JBoss Forge we will quickly generate a Java EE 7 web application, and then, following business requirements, we will add CDI functionalities.
This university talk will be a mixture of code and slides, focusing on CDI and Java EE 7.
--------
Video of the university is available on YouTube: http://youtu.be/LYKMaj4XKvg
Code and Slides on GitHub: https://github.com/antoinesd/cdi-forge-uni/tree/DevoxxBe2015
Probabilmente il framework javascript più atteso di sempre, evoluzione di uno dei framework più longevi ed usati nello sviluppo front end. Si vedranno alcune delle novità introdotte e delle scelte radicali fatte da Google per la nuova versione di Angular
As your app code gets larger and more complex, it makes sense to break your project out into smaller reusable components. But what’s the best way to do this? How can you clearly version your internal libraries? What kind of setup and maintenance can you expect? How much could it slow down development time?
In this talk we’ll dive into the various ways you can manage internal library dependencies. We’ll chat about the current state of Android dependency management, Gradle multi-project builds, Git submodules, and creating a private maven repository in Artifactory. The speaker will share real-world examples, and the pros and cons of each approach.
This presentation explains the benefits of Dagger 2, a Dependency Injections framework. It will be useful for Android developers.
The author of the presentation is Anton Minashkin (Android Developer, GlobalLogic); he delivered it at IT Saturday on June 6, 2015 in Kyiv.
Антон Минашкин
Android разработчик с 5-летним стажем. Сейчас занимает должность Android Developer в GlobalLogic . Выступал на UA Mobile'14 , конференции "IT- ПЕРСПЕКТИВА" , Kyiv Android gathering , Android Dev Club и др . Cоорганизатор сообществ GDG Kremenchuk и IT Kremenchuk .
Until now camera development has been very painful within android development. Although Camera2 API solved some of the problems in the original Camera API, however there were still lots of difficulties existed to write camera features. With the recent launch of JetPack CameraX support library, it aims to make camera app development easier by providing consistency and easy-to-use API that works on devices running Lollipop API-21 or above. In this talk, we will review main uses cases of CameraX Api which are preview, image analysis and image capture. We will also explore device-specific extensions such as portrait, HDR, night and beauty mode
Modularizing a project is never easy, a lot of files to move and the dependencies between them is not always what we expect. Then the Dagger configuration used in a single module project often doesn't scale well to a multi module project. Hilt is opinionated about the configuration to use (we don't need to argue anymore about using component dependencies or subcomponents!) and this configuration works perfectly even in a multi module project. In this talk we'll see first an introduction to Hilt and a comparison with Dagger to understand why it's easier to configure. Then we'll see how to leverage it in a multi module project (both in a standard layered architecture and in a Clean Architecture that uses the Dependency Inversion) to improve build speed and code testability. Spoiler alert: using sample apps that include a single feature in the app helps a lot!
Improving app performance with Kotlin CoroutinesHassan Abid
Coroutines were added to Kotlin in version 1.3 and since then they became a popular choice for android developers to simplify code that executes asynchronously. Coroutines are lightweight threads and on android they help to solve the primary problems of long running tasks that might block the main thread and also providing safety for offloading network or disk operations from the main thread. This talk covers how coroutines work with architecture components
Documentation: https://izumi.7mind.io/latest/release/doc/distage/
Github: https://github.com/pshirshov/izumi-r2
Pavel Shirshov - DIStage: purely functional programming without sacrificing modularity with modern dependency injection for Scala
- Modularity and its importance
- DI-like mechanisms and their issues in Scala
- Why people think that "DI doesn't compose with functional programming", and why that's not true
- Designing a staged DI, for wiring at runtime, at compile-time, or mixed
- Staging programs for reliability, power and performance
- The pains of supporting rich Scala types (incl. How to emulate kind-polymorphism in Scala 2)
- Garbage collection in DI for better tests and deployments
Pavel's bio: Language-agnostic software engineer, coding for 18 years,
10 years of hands-on commercial engineering experience.
Led a cluster orchestration team at Yandex, "the Russian Google"; implemented an internal orchestration solution, "ISS" (Scala/Java/C++), managing 50K+ physical hosts across 6 datacenters.
Today, Pavel owns Irish R&D company Septimal Mind.
Building Modern Apps using Android Architecture ComponentsHassan Abid
Android architecture components are part of Android Jetpack. They are a collection of libraries that help you design robust, testable, and maintainable apps. In this talk, We will cover LiveData, ViewModel, Room and lifecycle components. We will go through practical code example to understand modern android app architecture especially MVVM architecture.
In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design
Patterns are formalized best practices that the programmer must implement in the application.
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014First Tuesday Bergen
We are happy to invite you to the Speakers’ Corner today, on Thursday May 29, from 18.30 till 19.30 at SkyPoint to meet Thomas Vervik, Head of Development Bipper Communications who will talk on “How to save money on QA - Dependency Injection and automated testing on Android”
Thomas is Head of Development for Bipper Communications, and has been managing the company's team in Kiev since February 2012. Originally a seasoned Java server backend/frontend developer, he has the last two years started mobile development, first with HTML 5 and later Android.
Mobile development has since its birth around 2008 gone from simple apps to more complex enterprise similar software. The increase in size and complexity yields the need for structuring the code differently in order to handle the new complexity. The tools used to handle this complexity has been applied to server side development for years, but mobile development has been lagging behind.
But not anymore. New frameworks built on proven paradigms are emerging, and in this Speakers Corner we will introduce Dependency Injection for Android, the motivation for its use, and one of the implementations - Dagger. Dependency Injection has several advantages, but in this presentation we will focus on how it enables to write proper automated tests.
We are happy to invite you to the Speakers’ Corner today, on Thursday May 29, from 18.30 till 19.30 at SkyPoint to meet Thomas Vervik, Head of Development Bipper Communications who will talk on “How to save money on QA - Dependency Injection and automated testing on Android”
Thomas is Head of Development for Bipper Communications, and has been managing the company's team in Kiev since February 2012. Originally a seasoned Java server backend/frontend developer, he has the last two years started mobile development, first with HTML 5 and later Android.
Mobile development has since its birth around 2008 gone from simple apps to more complex enterprise similar software. The increase in size and complexity yields the need for structuring the code differently in order to handle the new complexity. The tools used to handle this complexity has been applied to server side development for years, but mobile development has been lagging behind.
But not anymore. New frameworks built on proven paradigms are emerging, and in this Speakers Corner we will introduce Dependency Injection for Android, the motivation for its use, and one of the implementations - Dagger. Dependency Injection has several advantages, but in this presentation we will focus on how it enables to write proper automated tests.
Slides from a talk and live-coding session about Koin, a pragmatic and lightweight Dependency Injection framework for Kotlin. This talk was given at Auckland Android Community on Dec 5.
https://www.meetup.com/Android-Meetup/events/256734688/
Dependency injection in Java, from naive to functionalMarian Wamsiedel
The presentation contains more approaches to implement inversion of control (dependency injection). There is a naive implementation, a standard guice implementation and two functional solutions.
The code samples are available on a github repository.
In this presentation i have talked about two frameworks that we can use to handle Dependency Injection in Android projects: Koin, Dagger. There's a short introduction and then i will use a sample to analyze the difference between them.
Similar to You Don't Need Dependency Injection (20)
Minął rok od prezentacji natywnego wsparcia podejścia MVVM na Google I/O. Przez ostatni rok mieliśmy okazję wykorzystywać to z wykorzystaniem Kotlina, oraz wypracować kilka uniwersalnych rozwiązań dla bolączek, z którymi boryka się Android. Pokażemy jak poradziliśmy sobie z runtime permissions, screen rotation oraz przechowywaniem stanu aplikacji bez użycia OnSaveInstanceState. Wszystko, aby móc pisać logikę biznesową odseparowaną od uwarunkowań systemu.
Autorzy: Michał Zawalich, Łukasz Roszak
Kod przykładowy do prezentacji: http://github.com/lrs-bls/mvvm-skeleton
Prezentacja wyjaśnia różnice pomiędzy wzorcami MVVM oraz MVC w kontekście iOS'a. Znajduje się w niej analiza dwóch prostych aplikacji: jedna korzysta ze wzorca MVVM, druga MVC
Core Location in details - presented by Piotr Tobolski on meet.mobile Lublin/Poland in May 2015. But the main part of the presentation was based on the demo app for testing CoreLocation framework - available at https://github.com/piotr-tobolski/CoreLocationDemo
Accelerate Enterprise Software Engineering with PlatformlessWSO2
Key takeaways:
Challenges of building platforms and the benefits of platformless.
Key principles of platformless, including API-first, cloud-native middleware, platform engineering, and developer experience.
How Choreo enables the platformless experience.
How key concepts like application architecture, domain-driven design, zero trust, and cell-based architecture are inherently a part of Choreo.
Demo of an end-to-end app built and deployed on Choreo.
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
A Comprehensive Look at Generative AI in Retail App Testing.pdfkalichargn70th171
Traditional software testing methods are being challenged in retail, where customer expectations and technological advancements continually shape the landscape. Enter generative AI—a transformative subset of artificial intelligence technologies poised to revolutionize software testing.
Enterprise Resource Planning System includes various modules that reduce any business's workload. Additionally, it organizes the workflows, which drives towards enhancing productivity. Here are a detailed explanation of the ERP modules. Going through the points will help you understand how the software is changing the work dynamics.
To know more details here: https://blogs.nyggs.com/nyggs/enterprise-resource-planning-erp-system-modules/
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
Software Engineering, Software Consulting, Tech Lead.
Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Security,
Spring Transaction, Spring MVC,
Log4j, REST/SOAP WEB-SERVICES.
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
Even though at surface level ‘java.lang.OutOfMemoryError’ appears as one single error; underlyingly there are 9 types of OutOfMemoryError. Each type of OutOfMemoryError has different causes, diagnosis approaches and solutions. This session equips you with the knowledge, tools, and techniques needed to troubleshoot and conquer OutOfMemoryError in all its forms, ensuring smoother, more efficient Java applications.
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
CyanicLab, an offshore custom software development company based in Sweden,India, Finland, is your go-to partner for startup development and innovative web design solutions. Our expert team specializes in crafting cutting-edge software tailored to meet the unique needs of startups and established enterprises alike. From conceptualization to execution, we offer comprehensive services including web and mobile app development, UI/UX design, and ongoing software maintenance. Ready to elevate your business? Contact CyanicLab today and let us propel your vision to success with our top-notch IT solutions.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
Into the Box Keynote Day 2: Unveiling amazing updates and announcements for modern CFML developers! Get ready for exciting releases and updates on Ortus tools and products. Stay tuned for cutting-edge innovations designed to boost your productivity.
5. „
Neversettle
intive.com
As a result I think we need a more specific name
for this pattern. Inversion of Control is too
generic a term, and thus people find it confusing.
As a result with a lot of discussion with various
IoC advocates we settled on the
name Dependency Injection.
-Martin Fowler
DI and Service Locator
7. Neversettle
intive.com
_DI
_Logic in two sets, integration with Pure Dependency injection or frameworks
!7Source: https://www.techyourchance.com/dependency-injection-android/
DI and Service Locator
8. Neversettle
intive.com
_DI
_Logic in two sets, integration with Pure Dependency injection or frameworks
_Common techniques:
_constructor injection
_method/setter injection
_field injection
!8
DI and Service Locator
9. Neversettle
intive.com
_Service Locator
_Object which holds services that an application might need
!9Source: https://martinfowler.com/articles/injection.html#ServiceLocatorVsDependencyInjection
DI and Service Locator
10. Neversettle
intive.com
_Service Locator
class ServiceLocator {
private Map services = new HashMap();
public Object getService(String key){
return services.get(key);
}
public void loadService(String key, Object service) {
services.put(key, service);
}
}
!10
DI and Service Locator
11. „
Neversettle
intive.com
With service locator the application class asks for it
explicitly by a message to the locator. With injection
there is no explicit request, the service appears in the
application class - hence the inversion of control.
- Martin Fowler
DI and Service Locator
14. Neversettle
intive.com
_Koin
_Runtime, lightweight service locator
_No code generation
_Based on Kotlin features
_0.2.0 version in 2017, current version is 0.9.3
_Written fully in Kotlin and works in Kotlin classes only
Dagger vs. Koin
!14
15. Neversettle
intive.com
_Field injection (Dagger)
class SearchActivity : AppCompatActivity() {
@Inject
lateinit var viewModel: SearchViewModel
override fun onCreate(savedInstanceState: Bundle?) {
AndroidInjection.inject(this)
(...)
}
}
Dagger vs. Koin
!15
34. Neversettle
intive.com
_Activity test
class SearchActivityTest : AutoCloseKoinTest() {
val tested = SearchActivity().testable()
val viewModel = mock<SearchViewModel>()
@BeforeEach
fun beforeEach() {
val testModule = applicationContext {
bean { viewModel }
}
loadKoinModules(testModule)
}
@Test
fun `should test something very important here`() {
tested.onCreate(mock())
tested.dataAdapter.itemCount `should equal` 0
}
}
Testing with Koin
!34
37. Neversettle
intive.com
_Pros
_Scales better (when using constructor annotations)
_Implementation of Dependency Injection
_Errors reported on build time
_Well known
_Cons
_Slow build time (code generation)
_Relatively hard to implement and understand
_Quite a lot initial boilerplate
Summary
!37
_Dagger
38. Neversettle
intive.com
_Pros
_Very simple to use and easy to debug
_Almost no initial boilerplate
_No code generation (reified trick)
_Cons
_Errors on runtime (dryRun could help)
_Pollutes app classes with by inject() (Service Locator)
_Kind of weird scoping but flexible
_Works only in Activities/Fragments written in Kotlin (by inject())
Summary
!38
_Koin
Bonus
Supports ViewModel
out of the box