Wednesday, July 15, 2020
Home > Beginners of Magento 2 > Dependency injection In Magento 2?

Dependency injection In Magento 2?

Web Development

Dependency Injection is a design pattern that allows an object A to declare its dependencies to an external object B that supplies those dependencies. The dependencies declared by A are usually class interfaces and the dependencies B provides are concrete implementations for those interfaces.

This allows for loose coupling of code because object A no longer needs to be concerned with initializing its own dependencies. Object B decides which implementations to provide to object A based on a configuration or desired behavior.

This is an important concept to understand for extension developers because it forms the basis of how Magento composes its classes.

Spread the love