CoursesAI WorkshopCompaniesPricingBlogConfAiBotSign inSubscribe
  • Courses
  • AI Workshop
  • Companies
  • Pricing
  • Blog
  • ConfAiBot
Subscribe
  • Courses
  • Companies
  • Communities
  • Blog
  • Gift card
  • Help
  • Shop
  • ConfAiBot
  • Contact
  • Legal notice
  • General conditions
  • Privacy policy
  • Cookies policy

SOLID - Dependency Inversion Principle

10 September 2015 | screencasts

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

  • [article] Inversion of Control Containers and the Dependency Injection pattern: Article by Martin Fowler about injection and dependency inversion
  • [paper] The Dependency Inversion Principle: Paper published by ObjectMentor
  • [tutorial] SOLID: Part 4 - The Dependency Inversion Principle: Series of tutorials from Tuts+ on SOLID
  • [post] The “D” Doesn’t Stand For Dependency Injection

Upcoming Videos

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

Tags

Code SmellsIntermediatePHPRefactoringSOLID
AnteriorInterview with Pablo Ros | Web Developer at Softonic and Uvinum
SiguienteSOLID - Single Responsibility Principle SRP and Interface Segregation Principle ISP

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
  • Receive job offers verified by Codely
  • Company invoice

premium

41,58 €
Save 89 €
Annual payment of 499 €
per month
  • All previous benefits
  • Early access to new courses
  • Discount on workshops

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