|
|
|
|
|
by sly010
4739 days ago
|
|
I understand dependency injection, but I never understood dependency injection frameworks. For me the whole point of DI is explicit composability.
There should only be a few well defined places in my application where all my classes are assembled into a working program. If my classes cover my domain nicely, I should be able to compose all kinds of programs (including tests) and reuse code. If my objects get injected to each other automatically by their name then my dependencies are just as predetermined, which results in coupled code, except the coupling is now difficult to read or modify. Once I decided I am only using explicit injection, I don't need a framework, I just instantiate my classes in the right order and pass them into each other. What can possibly be more pythonic than that? I have the same issue with Angular.js btw. They are trying to make is easy to start by adding dependency injection magic, but in reality all I see is "this can't possibly work (and indeed it doesn't)", so I just need to spend more time digging and understanding the magic before I can start writing ANY code. Every documentation should start by explaining the explicit way of doing things, then adding the sugar afterwards. import this |
|
/has just written a compile-time DI framework in scala using type-level programming. It's pretty sweet except for the compile times.