[Android] DependencyProperty Released
# What’s DependencyProperty
DependencyProperty is a library that resolves dependent objects with Delegated Properties.
DependencyProperty is a library of Service Locator patterns for use with manual DI. Dependencies can be easily defined and resolved with a simple concept and implementation. Classes that can access Application instances, such as Activity and Fragment, can take advantage of Delegated Properties to resolve dependent objects.
It also supports app design requirements such as ViewModel, UI Test, Dynamic Feature Module. ViewModel allows constructor injection without any special settings. UI Test can be set with less code than Dagger Hilt. It is also easy to use with multi-modules and Dynamic Feature Modules.
It doesn’t use code generation or reflection, so it builds faster than Dagger and runs faster than Dagger and Koin.
# Theme of DependencyProperty
Make Dependency resolution Simple Again.
No complicated concepts or settings like Dagger are required. Also, it’s not just a partial simplicity that looks like Koin. The concept itself is simplified so that it can be resolved simply.
# Concept of DependencyProperty
The basic concept is that resolving dependent objects using a manual DI in Domain and using a Service Locator in Presentation. DependencyProperty manages Domain generation logic and assists Service Locator.
Domain and Presentation here are Domain and Presentation of Presentation Domain Separation.
In Presentation, It is difficult to DI, so you can get it from Application instead. In Domain, you can use constructor injection.
# Components of DependencyProperty
To understand the concept of DependencyProperty, it is good to understand the following four components.
- DependencyModulesHolder
・interface holds DependencyModules
・Application is Service Locator by implementing this - DependencyModules
・collection object of DependencyModule
・add, update, and delete methods for scope and Dynamic Feature Module - DependencyModule
・marker interface
・Implements the generation logic of dependent objects - DependencyProperty
・Extension that resolves dependent objects with Delegated Properties
・Available from Activity, Fragment, etc. that can get Application
# About DependencyProperty
https://wada811.github.io/DependencyProperty/
How to use is listed.
https://github.com/wada811/conference-app-2020/pull/1
This is a sample of DroidKaigi 2020 conf app replaced with DependencyProperty. You can see the basic usage in the actual code.
This is a sample of https://github.com/wada811/iosched/pull/1 IOSched replaced with DependencyProperty.
You can check how to use it in Product Flavors, UI Test, etc. with actual code.
https://github.com/wada811/android-dependency-injection-performance/pull/1
Compares the performance of DI libraries. It’s basically the fastest.