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

SOLID design principles for better team performance

SOLID design principles for better team performance

A short overview of SOLID design principles with a practical example of how using them can improve team performance and reduce time needed to extend and maintain software.

Katerina Trajchevska

November 10, 2019

More Decks by Katerina Trajchevska

Other Decks in Programming


  1. SOLID design principles for better team performance Katerina Trajchevska, Bulgaria

    PHP 2019
  2. @ktrajchevska Katerina Trajchevska • Co-founder of Adeva, an exclusive developers’

    network. • Software Engineer & Mozilla Tech Speaker • Consultant with startups and Fortune 500 @ktrajchevska
  3. @ktrajchevska

  4. @ktrajchevska SOLID design principles ー Write code that’s easy to

    maintain. ー Easily extend the software with new functionality without breaking existing ones. ー Spend less time reading and more time writing code.
  5. @ktrajchevska A class should have only one reason to change.

    Single Responsibility Principle
  6. @ktrajchevska

  7. @ktrajchevska A class should be open for extension, but closed

    for modification. Open/Closed Principle
  8. @ktrajchevska

  9. @ktrajchevska Don’t switch implementations, unless they give the same result.

    Liskov Substitution Principle
  10. @ktrajchevska

  11. @ktrajchevska Don’t depend on methods you don’t use. Interface Segregation

  12. @ktrajchevska

  13. @ktrajchevska Depend on abstractions, not concretions. Dependency Inversion Principle

  14. @ktrajchevska

  15. @ktrajchevska Real Life SOLID Implementing developer profiles on Adeva’s Platform.

  16. None
  17. App\ZohoCandidate.php

  18. App\Http\Controllers\CandidateController.php Controller knows too much and is open for modification.

    Methods depend directly on the CRM storage and their naming conventions.
  19. profile.blade.php View uses arrays that should be replaced with Collections

    in future.
  20. App\Http\Controllers\CandidateController.php

  21. @ktrajchevska Changing storage from CRM to MySQL

  22. @ktrajchevska 1. Adjust the edit method to work with MySQL

  23. @ktrajchevska 2. Adjust the view to work with the new

  24. @ktrajchevska 3. Adjust the update method to work with MySQL

  25. @ktrajchevska 3. Adjust the update method to work with MySQL

  26. @ktrajchevska 3. Adjust the update method to work with MySQL

  27. @ktrajchevska What does it take to change the storage? 1.

    Add Eloquent models to use with MySQL. 2. Change controller dependencies from CRM class to Eloquent. 3. Use Eloquent instead of CRM to pull data for the view. 4. Switch all variables to the new naming convention. 5. Change the way we access data in the views. 6. Adjust the unit tests to work accordingly.
  28. @ktrajchevska Time to switch: 30 days

  29. @ktrajchevska How can we improve team performance by using SOLID

    design principles?
  30. @ktrajchevska 1. Segregate the interfaces.

  31. @ktrajchevska App\Repositories\Interfaces\CandidateRepositoryInterface.php

  32. @ktrajchevska 2. Don’t depend on concrete implementations.

  33. @ktrajchevska App\Repositories\ZohoCandidateRepository.php

  34. @ktrajchevska App\Http\Controllers\CandidateController.php

  35. @ktrajchevska 3. Be mindful about what your program expects.

  36. @ktrajchevska App\Crm\Candidate.php

  37. @ktrajchevska profile.blade.php

  38. @ktrajchevska 4. Separate the responsibilities.

  39. @ktrajchevska

  40. @ktrajchevska 5. Close the code for modification.

  41. @ktrajchevska App\Providers\AppServiceProvider.php

  42. @ktrajchevska Changing storage from CRM to MySQL: Take #2

  43. @ktrajchevska

  44. @ktrajchevska What does it take to switch the storage? 1.

    Add Eloquent models to use with MySQL. 2. Create MysqlCandidateRepository that implements CandidateRepositoryInterface. 3. Change the binding for CandidateRepositoryInterface.
  45. @ktrajchevska Time to switch: 5 days

  46. @ktrajchevska Better team performance with SOLID ー Spending less time

    reading code. ー Reducing time needed to extend the software. ー Reducing bugs by closing the core of the system. ー Improving productivity and reducing costs.
  47. @ktrajchevska Is SOLID a “one size fits all” ?

  48. @ktrajchevska ⚠ “Refactor away from SRP”

  49. @ktrajchevska

  50. @ktrajchevska Software Design Principles are your tools, not your goals.

  51. @ktrajchevska Thank you!