In modern coding patterns, factory level containers that help assemble components eventually into a cohesive application have become very important. Beneath such type of containers, there is a common pattern which defines how to perform the wiring of different components together and is known as Inversion of Control (IoC). The pattern coming out of it is more specifically known as Dependency Injection.
Dependency injection
Introducing dependency injection
Dependency Injection design pattern fulfills the dependency inversion principle of the SOLID design principles. There are three main forms of dependency injection:
- Constructor injection: An example of this is shown in the DIP section
- Setter injection: Let's look at an example code for setter injection:
...