solid design
TRANSCRIPT
Hello there!
Who am I?
Yoan-Alexander GrigorovPHP developer (with pride!)Software EngineerCriticDesign Patterns adventurer
SOLID design?
Imagine code as a painting
Well... maybe not this one in particular!
Now that's better!
Nothing against modern art, but...
Code should be easy to recognize!
How a project starts:
Several months later...
What is going wrong?
Frequently logic changes are made with hacks without refactoring
Lack of knowledge on stuff
Lack of discipline
SOLID? What's that?
Single responsibility
Open-closed
Liskov substitution
Interface segregation
Dependency inversion
What SOLID can't do?
Cure ebola
Explain why is there PHP 7 coming out, but no PHP 6?!?!?
Make Bulgarian politicians suck less
Let's break it down!
Single responsibility principle
Every variable, class, function, etc. should have a single responsibility, described in it's name (if any).
Single responsibility principle
Basically it's bad if we have a function (or class) that does more then what it's name says.
Single responsibility principle
Here is one real-life example how bad it is to break this rule:
Single responsibility principle
Hidden features can have unexpected effects
Single responsibility principle
Bad code example: