Summary

Dependency Injection is a technique to help us produce loosely coupled code by moving the concern of creating the dependencies to another object known as a DI container. In other words, instead of a dependent object to decide what concrete class it needs, it just states the needs as an abstraction, and the injector provides it with the most suitable concrete class that satisfies the needs. Loose coupling is one of the main advantages of DI that leads to extensibility, maintainability, and testability. Late binding is another benefit of DI and dynamic loading of plugins is an example of this feature. There are DI containers other than Ninject, each of which has their own advantages and disadvantages.

Get Mastering Ninject for Dependency Injection now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.