We just keep inventing special ways to make things more complex and magic, when what we really need is to accept that simplicity is a virtue.
We just keep inventing special ways to make things more complex and magic, when what we really need is to accept that simplicity is a virtue.
I don't see dependency injection as a good thing. It's complexity added to try and make up for other complexities. I've never seen a dependency injection system implemented in any language that wasn't unnecessarily difficult to understand or that didn't have gotchas. All of that wouldn't be needed if most things were written as functions (i.e. no ImageThumbnailHttpUploader class), or if class instances were always invoked directly without magic.
I've grown to dislike Spring DI, Google's Guice and friends. You can use basic constructor injection and wire it up in your main method with zero dependencies or framework and it ends up simpler, easier to reason about. Java has also had Lambda's for a long time now so sometimes all you need to do is pass in a Lambda.
This is even a simplification. Just why...
Then you can't provide a test seam.
Dependency injection + mocking is a very powerful concept.
Definitely. I do 99% of my dependency injection as constructor "injection".
Injection frameworks and Whitebox testing just introduce layers of complexity that can be very difficult to debug
Definitely. I do 99% of my dependency injection as constructor "injection".
Injection frameworks and Whitebox testing just introduce layers of complexity that can be very difficult to debug