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

Better Code Design in PHP

Better Code Design in PHP

Are you tired of spending hours reading code just to find the right place to make a small change? Are you forced to split your application into several just so that devs don't step on each other's toes? This talk unites theory with practice to show you how to structure your code so that it is easy to read, to test and to maintain. You will step out with concrete ideas of how to improve your code design.

Anna Filina

August 17, 2024
Tweet

More Decks by Anna Filina

Other Decks in Programming

Transcript

  1. I Stand With Ukraine Anna Filina • Coding since 1997.

    • PHP, Java, C#, etc. • Legacy archaeology. • Test automation. • Talks and workshops. • YouTube videos. • Filina Consulting.
  2. I Stand With Ukraine Design Drive • Avoid complexity until

    I need it. • Do I understand what’s going on in terms of the business use case?
  3. I Stand With Ukraine Project • Marketplace for short-term rental:

    • Search properties for rent by city, date and number of guests. • Reserve & pay.
  4. I Stand With Ukraine ReservationService ->reserve() PaymentManager ReservationManager processPayment(data) Templating

    saveReservation(data) confirmReservation(data) html EmailManager payment savePayment(data) confirmReservation(html)
  5. I Stand With Ukraine ReservationService ->reserve() PaymentManager ReservationManager processPayment(data) Templating

    saveReservation(data) confirmReservation(data) html EmailManager payment savePayment(data) confirmReservation(html)
  6. I Stand With Ukraine Simple Code • No need for

    framework. • No need to design the database. • No need to have a UI. • Code the business rules.
  7. I Stand With Ukraine Handle HTTP Request Return HTTP Response

    2 adults in Lviv on Jan 1 to Jan 7 Results containing “Lviv for 4”
  8. I Stand With Ukraine Handle HTTP Request Return HTTP Response

    2 adults in Lviv on Jan 1 to Jan 7 Results containing “Lviv for 4”
  9. I Stand With Ukraine A complex system that works is

    invariably found to have evolved from a simple system that worked. — John Gall
  10. I Stand With Ukraine PropertySearchHandler Lviv, Lviv Oblast, Ukraine Convert

    to coordinates. CitySearchHandler Lviv - Lviv, Lviv Oblast, Ukraine - Lviv Boulevard, Oshawa, ON
  11. I Stand With Ukraine PropertySearchHandler 49.8397, 24.0297 Longitude: -180 to

    +180 Latitude: -90 to +90 CitySearchHandler Lviv Lviv, Lviv Oblast, Ukraine 49.8397 24.0297
  12. I Stand With Ukraine Code is simply a model of

    the business rules and knowledge.