Sep 5, 2018 · 1 min read
Any reason why I always see DI used with interfaces? Couldn’t one just use concrete classes? You briefly mention that one may have to pay for calls to a service or that network communications could introduce slowness, and I get that.
But…
What if you wanted to test ALL of that… network slowness and all? What if you are making network calls or database calls from a repository but that repository method is being called in a business logic component with exception handling, logging, etc? What if we want to test all of that?
is it ever acceptable to forgo an interface and just directly inject objects?