I'm trying to create modular architecture for my Android app and now I'm looking into Dagger DI library. It's really awesome tool, but I don't want to misuse it and currently I have numerous questions like:
- Should I wrap everything (like Activities or Fragments, or event separate Views) into modules or only common used parts of app (likes services for querying data with login, data layer)?
- Better use with Android annotations. Android Annotations is another cool library I faced but it seems to play well with UI layer making easy ealing with Views, Fragments and removing some boilerplate code. But how doest it play with Dagger?
If you have a good example of open source project using DI please refer to me. I really want to follow best practices.
Dependency injection is usually used to add a layer of separation and makes things even less coupled. For Android the library I recommend is Dagger2.
I would really suggest you to check this boilerplate since it is fully based on DI using Dagger2.
The dependencies currently handled by the boiler plate are the following:
The power of dependency injection comes really handy especially for testing since you can easily switch your dependencies in the test environment to dummy dependencies.
Take a look at: