Slide 1

Slide 1 text

FROM GOOD TO SOLID How to become a better PHP Developer?

Slide 2

Slide 2 text

Katerina Trajchevska Software engineer & CEO of Adeva ● Consultant with startups and Fortune 500 ● Remote work advocate ● Community volunteer

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Why?

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Moving to a Local Database?

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

3 2 1 8 changes in a single method

Slide 13

Slide 13 text

@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.

Slide 14

Slide 14 text

1 2 3 ⚠ Violation of Single Responsibility Principle 4

Slide 15

Slide 15 text

⚠ Violation of Open/Closed Principle

Slide 16

Slide 16 text

⚠ Violation of Dependency Inversion Principle ⚠ Violation of Interface Segregation Principle

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

@ktrajchevska ⚠ Violation of the Liskov Substitution Principle

Slide 20

Slide 20 text

@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

Slide 21

Slide 21 text

@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.

Slide 22

Slide 22 text

Segregate the interfaces.

Slide 23

Slide 23 text

Separate the responsibilities.

Slide 24

Slide 24 text

Think about the substitutions.

Slide 25

Slide 25 text

Depend on abstractions. Extend by adding, not modifying.

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

@ktrajchevska ZOHO to Local, take 2

Slide 28

Slide 28 text

@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.

Slide 29

Slide 29 text

Thanks! @ktrajchevska Connecting tech companies with world-class developers