Does dagger 2 has any benefit for performance?
The main idea is to decouple the classes to make the code easier to test and maintain as there are no hard dependecies. As I am not that good with explanations, I suggest you take a look at the following articles in case you haven't read them yet.
MVP and DI:
- Part 1
- Part 2
- Part 1
- Part 2
I hope this answers any of your questions!
I want to concentrate on memory and performance of the application with dependency injection. So, I found this answer in android developer website. https://developer.android.com/topic/performance/memory.html#DependencyInjection :
Use Dagger 2 for dependency injection frameworks
can simplify the code you write and provide an adaptive environment that's useful for testing and other configuration changes.
If you intend to use a dependency injection framework in your app, consider using Dagger 2. Dagger does not use reflection to scan your app's code. Dagger's static, compile-time implementation means that it can be used in Android apps without needless runtime cost or memory usage.
Other dependency injection frameworks that use reflection tend to initialize processes by scanning your code for annotations. This process can require significantly more CPU cycles and RAM, and can cause a noticeable lag when the app launches.
Performance is up to developer to avoid inefficient use of resources, such as the CPU, memory, graphics, network, and device battery. But dependence injection is a design pattern that is based on the concept of Inversion of Control which says that a class should get its dependencies from outside. In simple words, no class should instantiate another class but should get the instances from a configuration class instead of constructing them internally. So, this pattern allows developers to write code that has low coupling and which can therefore be easily tested and maintained.
But to compare the Performance of Dependency Injection Libraries , see this good link : http://blog.nimbledroid.com/2016/03/07/performance-of-dependency-injection-libraries.html