Dependency Inversion Principle (PHP SOLID Design Principles)

preview_player
Показать описание
The #DependencyInversion Principle is most notable for being the D in the infamous #SOLID Design Principles.

The dependency inversion principle states that higher level modules should not depend on low level modules ~ both higher and lower level modules should depend on abstractions. Abstractions should not depend on details.

Details should depend upon abstractions.

Dependency Inversion is one of the most powerful design patterns out there due to it allowing us to invert our dependency tree, but out of all of the SOLID Principles ~ Dependency Inversions is probably the most complicated...at first glance.

1. Higher level modules: Accept Abstraction As Parameter Or Argument
2. Lower level modules: Implement Abstraction's behavior
3. Higher level modules depend on abstract by accepting them as arguments while lower level modules depend on abstractions by implementing the required behavior demanded by the interface.

The lower level module is responsible for implementing the required behavior.

Dependency Inversion. #ObjectOrientedDesignPatterns

~~~~~~~~~~~~~~~~~~~~~~
Clean Code Studio ~ Simplify!
Clean Code Clean Life
Рекомендации по теме
Комментарии
Автор

The fact that I was watching this while at the toilet totally enhanced the learning experience.

Thanks so much for a great video!

dawid_dahl
Автор

I'm a bit late to the party but this has refreshed my knowledge ready for my interview! Thank you!

thisdotadam
Автор

This one is technically A Dependency "Injection" Focused Lesson.

That being said, we also cover Dependency "Inversion" in a more visualized way in this lesson. I'd recommend watching this lesson, then if Dependency Inversion doesn't click all the way move on over and check out this lesson on "Dependency Injection". Mid way through, we dive into how we can use Dependency "Injection" to implement Dependency "Inversion". We break down higher level modules and lower level modules and a very visually understanding way.

CleanCodeStudio
Автор

Cool example Thank you @CleanCodeStudio!

lizamali
Автор

??? but methods dont depend on classes so i dont really get the problem it tries to solve

JoshuaKisb