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

From Good to SOLID: How to become better PHP developer

From Good to SOLID: How to become better PHP developer

Slides for the PHP UK 2019 keynote on SOLID design principles and using them to become better PHP developers.

Learn how you can incorporate the SOLID design principles in your daily work to reduce the development time.


Katerina Trajchevska

February 22, 2019


  1. FROM GOOD TO SOLID How to become a better PHP

  2. Katerina Trajchevska Software engineer & CEO of Adeva • Consultant

    with startups and Fortune 500 • Remote work advocate • Community volunteer
  3. None
  4. Why?

  5. None
  6. None
  7. None
  8. None
  9. Moving to a Local Database?

  10. None
  11. None
  12. 3 2 1 8 changes in a single method

  13. @ktrajchevska SOLID Design Principles • Single Responsibility Principle: do only

    one thing in a class. • Open-Closed Principle: extend, don’t modify. • Liskov Substitution Principle: don’t switch classes, unless you’re sure they give the same result. • Interface Segregation Principle: create small interfaces. • Dependency Inversion Principle: depend on interfaces, not classes.
  14. 1 2 3 ⚠ Violation of Single Responsibility Principle 4

  15. ⚠ Violation of Open/Closed Principle

  16. ⚠ Violation of Dependency Inversion Principle ⚠ Violation of Interface

    Segregation Principle
  17. None
  18. None
  19. @ktrajchevska ⚠ Violation of the Liskov Substitution Principle

  20. @ktrajchevska What does it take to move to a local

    database? • Create Eloquent models for new database tables. • Change all controller dependencies (Eloquent instead of Third Party API). ◦ Registration process, edit profile process ◦ Admin panel: managing candidates (CRUD), creating candidate profiles, creating proposals... • Change controller logic to adapt to the storage change. • Change all views. • Adapt the unit tests, retest everything. • Estimated time for migration: 30 days
  21. @ktrajchevska We can do better than this 1. Separate the

    responsibilities in specific classes. 2. Design the code in a way that allows extending by adding, not modifying. 3. Be aware of the return types: know what you expect. 4. Don’t depend on concrete implementations. 5. Don’t depend on unnecessary methods.
  22. Segregate the interfaces.

  23. Separate the responsibilities.

  24. Think about the substitutions.

  25. Depend on abstractions. Extend by adding, not modifying.

  26. None
  27. @ktrajchevska ZOHO to Local, take 2

  28. @ktrajchevska How to become better PHP developers? • Incorporate thoughtful

    programming. • Think about the UX of your code. • Use SOLID design principles to create software that’s easy to extend and maintain. • Think of SOLID as your tool, not your goal. • Don’t laugh at PHP jokes.
  29. Thanks! @ktrajchevska Connecting tech companies with world-class developers