4 ms·
DI usually means Dependency Injection, and I don't see how I could do unit testing/mocking without DI (especially constructor based DI). IoC containers such as
by guiomie 11y ago
DI usually means Dependency Injection, and I don't see how I could do unit testing/mocking without DI (especially constructor based DI). IoC containers such as AutoFac, those are from my perspective more of a fad.
- rjbwork 11y agoWhy do you consider them a fad? I've found it immensely useful to not go through the rigamarole of newing up a ton of objects manually in my web controllers and queue/batch processing frameworks. Just choose your composition roots properly and you can easily add new endpoints/jobs/event processors without all the worry of resolving all the dependencies manually. It also allows you to reduce footprints (setting non-stateful code/configuration objects as singletons), transparently cache and instrument(dynamic proxies, or application specific caching/logging wrappers), and other similar application-level concerns without it infecting consuming code or otherwise independent modules.
- guiomie 11y agoBy fad, I meant that the frameworks change in the world of IoC, while DI is pretty much a concept easily applicable in OO languages. I myself and my team use AutoFac right now, but who knows what it could be in 1-2 years...