Adding Guice modules for existing components
li2109 opened this issue · comments
I was hesitant to use Guice or any other dependency injection framework(I actually tried but deleted it later on) as I am afraid the decision would enforce every user who is using our library to use Guice or Spring.
The consequence without DI is that components are tightly coupled.
: (
This makes me feel worse.
After research, it turns out it shouldn't matter.
There's https://github.com/spring-projects/spring-guice that could help convert the Guice module to the corresponding part in Spring.
Even without the repo above, we can also do this: https://stackoverflow.com/questions/18826308/integrate-guice-component-into-spring-application
As we are switching to the dependency injection way, some code will need to be changed. For example, we would write less static factory methods that we did a lot. It makes no sense to create it if we are instantiating via the injection.
#121 PR merged