I\'m still at the beginning in learning scala in addition to java and i didn\'t get it how is one supposed to do DI there? can or should i use an existing DI library, should it
A recent project illustrates a DI based purely on constructor injection: zalando/grafter
What's wrong with constructor injection again?
There are many libraries or approaches for doing dependency injection in Scala. Grafter goes back to the fundamentals of dependency injection by just using constructor injection: no reflection, no xml, no annotations, no inheritance or self-types.
Then, Grafter add to constructor injection just the necessary support to:
- instantiate a component-based application from a configuration
- fine-tune the wiring (create singletons)
- test the application by replacing components
- start / stop the application
Grafter is targeting every possible application because it focuses on associating just 3 ideas:
- case classes and interfaces for components
- Reader instances and shapeless for the configuration
- tree rewriting and kiama for everything else!