Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dependency Injection for beginners

David Frame
February 04, 2016

Dependency Injection for beginners

Slides for my talk at the 16th PHP Belfast Meet-up.

David Frame

February 04, 2016
Tweet

More Decks by David Frame

Other Decks in Technology

Transcript

  1. Dependency Injection David Frame of 31interactive

  2. ?

  3. Scenario #1 We need to be able to test our

    order class without sending any emails!
  4. Dummy mailer class with a send() method that does nothing!

  5. What is dependency injection?

  6. None
  7. Single Responsibility Principle a class should have only a single

    responsibility Open / Closed Principle “software entities … should be open for extension, but closed for modification.” Liskov Substitution Principle Interface Segregation Principle Dependency Inversion Principle one should “Depend upon Abstractions. Do not depend upon concretions.”
  8. Scenario #2 We need to store emails in the database

    so they can be queued up and sent at a later date!
  9. None
  10. None
  11. None
  12. Dependency Injection Containers

  13. None
  14. Thanks for listening! Any questions? :) Email: david.grant.frame@gmail.com Twitter: @DaGrFr

    Review this talk at https://joind.in/16984