Is dependency injection bad?
Actually this post is not really about dependency injection (DI) but that is where I am going to start.
I saw this post by someone saying that DI is bad, horrible. I see posts like this pretty regularlly about any thing related to tech: DI, design patterns, ORM, stored procedures, unit tests, mocking, all of it.
I have noticed a pattern with these types of posts--most people who write the posts come from 1 of 2 backgrounds. Either they do not understand the tech or they've been in environments where the tech was misappropriated. I came into a project one time with engineering's primary goal was ripping out interfaces--mostly wholesale, just getting rid of it. A couple of years later, we were adding back interfaces. The problem was not interfaces.
The problem was lack of correct application. Neither creating all of those interfaces the first time, nor ripping them all out the second time was right solution because in both cases they failed to apply good analysis and understanding of when and where interfaces make sense vs when they create problems.
Way to often in engineering we look for that one killer solution that fixes everything. We need to change the thinking there is a single broad stroke solution to every problem. And start finding the right tech for the problem each time.
Is DI good or bad? It depends on how you use it and what you expect from it. Same for anything else.
Comments
If you'd like to comment on this post, please reach out to me through the contact page .