| I don't get dependency injection. I come from languages that I am told don't have it. But when I read the Wikipedia page for DI, I get: "a dependent consumer a declaration of a component's dependencies, defined as interface contracts an injector (sometimes referred to as a provider or container) that creates instances of classes that implement a given dependency interface on request." Wait, I still have to declare dependencies, just like the import statement in python, require.js in JS, etc. which are apparently not 'dependency injection' systems? And this just adds, er more code? That same wikipedia page mentions dynamically loaded dependencies while also mentioning 'a declaration of a components dependencies' which sure doesn't sound dynamic to me. Does anyone care to provide a better explanation of what dependency injection gives me over the existing common dependency mechanisms? |
Building Java like DI mechanisms is cargo cultism. The whole point of DI in Java is to work around its static typedness, so one can perform runtime binding of components in a dynamic manner.
Three quarters of cool Java and .NET "design patterns" are just band aids around semantic limitations of these languages.