3 ms·
I mainly know OO through Python. I had a Java programmer try and explain why Dependency Injection frameworks were great and I went off and googled around and th
by andybak 16y ago
I mainly know OO through Python. I had a Java programmer try and explain why Dependency Injection frameworks were great and I went off and googled around and there are a few for Python.
I still can't grok why I'd need one though. Is DI for Python the product of damaged minds or do they provide some real benefit?
- JulianMorrison 16y agoEven in Python, you benefit from structuring an object to accept its dependencies as inputs, rather than calling to them by their global names. It lets you test each class independently with mock objects that support the same interface.
- andybak 16y agoBy writing XML config files? (or is that just a Struts wart rather than an intrinsic part of DI?) Anyway - if mocking for tests is the major benefit of DI then there some other simpler ways to that. Everything I've read on DI makes it sound like a fairly complex beast.