0 votes
in Magneto by
What is Dependency Inversion Principle

1 Answer

0 votes
by

Magento follows the dependency inversion principle to reduce code dependencies using abstractions in your code.

Your high-level classes should use the interfaces of low-level classes instead of working with them directly.

Utilizing interfaces in your code decreases the risk of incompatibility bugs when Magento modifies the underlying implementation of the interfaces. It also lets you focus on what a class does instead of how it is implemented.

Considering that the Magento codebase supports this principle, you can map your implementation of a Magento interface to a dependent service or class using the di.xml file.

When this principle is applied, it means high-level classes are not working directly with low-level classes.

Related questions

0 votes
asked Nov 9, 2020 in Magneto by sharadyadav1986
0 votes
asked Mar 9, 2022 in Magneto by sharadyadav1986
...