2 ms·
I don't understand the point of this implementation. If you have to call di.get("A") in __init__, why is it better than just instantiating A() directly? It's no
by kissgyorgy 5y ago
I don't understand the point of this implementation. If you have to call di.get("A") in __init__, why is it better than just instantiating A() directly? It's not even a dependency injection I guess, as the framework should take care of the automatic instantiation of objects without the object having to know even that a Di is in place.
- jseban 5y agoYeah it doesn't make any sense, the whole point of DI is to work around Java's static type system to enable mocking for testing, which is a problem you don't have outside of static typing. But the "why" around these design patterns have been long lost, and people will argue to death that the patterns should always be used in every language/runtime and come up with ever more vague and circular reasons until you can't argue against it.