SOLID - Dependency Inversion Principle

In this second video of the SOLID series, we will see what the Dependency Inversion Principle is and what benefits it brings. As always, we will approach it in the most practical way possible, refactoring code to apply this principle. In the previous videos, we already saw how to configure namespaces following PSR-4 and use Composer's autoloader, how to apply the PSR-2 coding style standard, and, more specifically in the SOLID series, we have already seen the Single Responsibility Principle and Interface Segregation Principle. I recommend you take a look at them :)

Video Index

  • 1:03 - Explanation of base code (context)
  • 2:50 - Scenario 1: Highly Coupled Code and creating instances of collaborators at the point they are needed
    • 3:55 - Why is code coupling bad?
    • 6:10 - Class diagram of scenario 1
  • 7:10 - Scenario 2: Refactoring to introduce the concept of dependency injection. Highly coupled code but creating instances of collaborators outside the client class
    • 9:00 - What benefits does dependency injection have?
  • 10:39 - Scenario 3: Refactoring to apply the Dependency Inversion Principle (Dependency Inversion Principle, DIP). Decoupled and changeable code.
    • 11:38 - Explanation of the introduced interface. Design by contract
    • 13:35 - What benefits does dependency inversion have?
    • 15:30 - Class diagram applying the dependency inversion principle
    • 16:05 - Dependency inversion explained like you've never seen before :D

Video

Related Material

Upcoming Videos

  • Interview!
  • DTOs / Anemic Domain Models vs Domain Models (Intermediate)
  • Composition over Inheritance - A Turning Point (Intermediate)

Pay according to your needs

lite (only monthly)

19 €
per month
  • Access to a subset of courses to lay the foundation for maintainable, scalable, and testable code
  • Company invoice
Popular

standard

24,92 €
Save 121
Annual payment of 299
per month
  • Full course catalog
  • Design and architecture challenges
  • Highlighted solutions videos for challenges
  • Receive job offers verified by Codely
  • Company invoice

premium

41,58 €
Save 89
Annual payment of 499
per month
  • Everything above
  • More benefits coming soon

We won’t increase the price while your subscription is active