IDG Contributor Network: Exploring the dependency injection principle
The Dependency Inversion Principle states that the high level modules in an application should not depend on the low level modules; both should rather depend on abstractions.
Both inversion of control and dependency injection are ways that enable you to break the dependencies between the components in your application. The IOC design pattern states that objects should not create objects on which they depend to perform some activity.
As an example, you would typically have a business layer and a core or framework layer in your application. The business layer code should invoke the framework layer code. Using the IOC principle, this can be inverted, i.e., the framework layer would call the business layer. The IOC containers helps you in automatic instantiation and life cycle management of the objects. Some examples of popular IOC containers include Castle Windsor and Structure Map.
To read this article in full or to leave a comment, please click here
