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
Tweet

More Decks by Katerina Trajchevska

Other Decks in Programming

Transcript

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

    with startups and Fortune 500 • Remote work advocate • Community volunteer
  2. @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.
  3. @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
  4. @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.
  5. @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.