Well said. It strikes me, though, that a key factor in the usefulness of DI is that the latter concern can potentially be influenced by the former (depending on what’s being injected). This is not the case in a traditional delegation scenario.
Richard
DI is a simple concept of decoupling a class from instantiating all the other classes it needs to do its business. The class can just assume that the other required class instance will just be there when it needs them at runtime. The class creation is done by the framework/container.
A book for Tech Leads, from Tech Leads. Discover how more than 35 Tech Leads find the delicate balance between the technical and non-technical worlds. Discover the challenges a Tech Lead faces and how to overcome them. You may be surprised by the lessons they have to share.
Well said. It strikes me, though, that a key factor in the usefulness of DI is that the latter concern can potentially be influenced by the former (depending on what’s being injected). This is not the case in a traditional delegation scenario.
DI is a simple concept of decoupling a class from instantiating all the other classes it needs to do its business. The class can just assume that the other required class instance will just be there when it needs them at runtime. The class creation is done by the framework/container.
http://www.javasimplified.info/javasimplified/posts/list/3.page