When we modularize our code base into CFCs using Object-Oriented Programming principles, our objects will often begin to rely on other objects to function as intended. When one part of our application relies on another part of the application to function, we have what is called a dependency. While we want our objects to know how to use the objects that they depend on, we do not want our objects to be responsible for creating and configuring the objects that they need – we want to maintain loose coupling and keep a separation of concerns.
In order to keep a separation of concerns we want to manage any dependencies between objects outside of the objects themselves. This can be accomplished by leveraging an Inversion of Control (IoC) framework such as ColdSpring. ColdSpring features a design pattern called Dependency Injection (DI) to help to assemble the components needed for the application to work. Dependency Injection manages the dependencies between objects by … wait for it … injecting the dependencies into the objects that rely on the objects to function.
The following demo application is an simple example on how to use ColdSpring to manage your object dependencies in your application.
Read more ...