|
|
|
|
|
by eru
710 days ago
|
|
I've asked a similar question, along the lines 'Can you explain Dependency Injection to me, assuming I already know Haskell?' And the answer was basically along the lines of: it's a fancy way to pass something like a function argument. |
|
The big picture of what a DI framework does is let you declare your structural object graph using a config file or decorators and have the whole thing instantiated at runtime automagically.
The detailed view is "a fancy way to pass something like a function argument". An object that has dependencies gets them passed in ("injected") at runtime rather than calling dependent function directly or internally instantiating dependent objects and calling them.
Doing things this way in OO languages has a number of benefits, including improved testability.