don't be stupid, grasp solid - north east php
DESCRIPTION
Object Oriented Design talk at North East PHPTRANSCRIPT
![Page 1: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/1.jpg)
Don’t Be STUPIDGrasp SOLID!
Anthony FerraraNorthEastPHP 2013
![Page 2: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/2.jpg)
Let’s TalkObject
OrientedProgramming
![Page 3: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/3.jpg)
WhatIs An
Object?
![Page 4: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/4.jpg)
Classic View
Object == Physical “Thing”
![Page 5: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/5.jpg)
Classic View
Object == Physical “Thing”
Methods == Actions on “Thing”
![Page 6: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/6.jpg)
Classic View
Object == Physical “Thing”
Methods == Actions on “Thing”
Properties == Description of “Thing”
![Page 7: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/7.jpg)
Animal
MammalBird Fish
CatCow Dog
Lion Feline Cheetah
![Page 8: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/8.jpg)
Classic View
$lion = new Lion;$lion->roar();$lion->walkTo($point);$lion->hunt($zebra);$lion->sleep();
![Page 9: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/9.jpg)
Is This Realistic?
![Page 10: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/10.jpg)
Classic View
$lion = new Lion;$lion->roar();$lion->walkTo($point);$lion->hunt($zebra);$lion->sleep();
![Page 11: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/11.jpg)
Classic View
$lion = new Lion;$lion->roar();$lion->walkTo($point);$lion->hunt($zebra);$lion->sleep();
Does A Lion Have A Button To Make It Roar?
![Page 12: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/12.jpg)
Classic View
$lion = new Lion;$lion->roar();$lion->walkTo($point);$lion->hunt($zebra);$lion->sleep();
Does A Lion Have A Button To Make It Roar?What Does It
Mean For An Object To “Hunt”?
![Page 13: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/13.jpg)
Classic View
$lion = new Lion;$lion->roar();$lion->walkTo($point);$lion->hunt($zebra);$lion->sleep();
Does A Lion Have A Button To Make It Roar?What Does It
Mean For An Object To “Hunt”?
What Is A Lion In Relation To Our Application?
![Page 14: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/14.jpg)
The Classical Model Is Easy To
Understand
![Page 15: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/15.jpg)
![Page 16: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/16.jpg)
The Classical Model Is
Completely Impractical
![Page 17: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/17.jpg)
“Modern” View
Object == Collection Of (Related) Behaviors
![Page 18: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/18.jpg)
“Modern” View
Object == Collection Of (Related) Behaviors
Methods == Behavior
![Page 19: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/19.jpg)
“Modern” View
Object == Collection Of (Related) Behaviors
Methods == Behavior
Properties == Details Of Behavior
![Page 20: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/20.jpg)
Classic View == “(conceptually) is a”
Modern View == “behaves as a”
![Page 21: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/21.jpg)
interface Number {
function getValue(); function __toString();
function add(Number $n); function subtract(Number $n);
function equals(Number $n); function isLessThan(Number $n); function isGreaterThan(Number $n);
}
![Page 22: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/22.jpg)
Number
IntegerFloat Decimal
longshort long long
unsigned signed
![Page 23: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/23.jpg)
But Wait!
![Page 24: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/24.jpg)
We Don’t Even Need Inheritance
![Page 25: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/25.jpg)
All We Need IsPolymorphism
And Encapsulation
![Page 26: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/26.jpg)
![Page 27: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/27.jpg)
Polymorphism
Behavior Is Determined Dynamically
“Dynamic Dispatch”
![Page 28: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/28.jpg)
Procedural Code
if ($a instanceof Long) { return new Long($a->getValue() + 1);} elseif ($a instanceof Float) { return new Float($a->getValue() + 1.0);} elseif ($a instanceof Decimal) { return new Decimal($a->getValue() + 1.0);}
![Page 29: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/29.jpg)
Polymorphic Code
return $int->add(new Integer(1));
![Page 30: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/30.jpg)
Polymorphic Code
class Integer implements Number { public function add(Number $a) { return new Integer( $this->getValue() + (int) $a->getValue() ); }}
![Page 31: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/31.jpg)
Polymorphic Code
class Float implements Number { public function add(Number $a) { return new Float( $this->getValue() + (float) $a->getValue() ); }}
![Page 32: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/32.jpg)
Encapsulation
Behavior Is Completely Contained By The Object’s API
(Information Hiding)
![Page 33: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/33.jpg)
Procedural Code
if (5 == $number->value) { print “Number Is 5”;} else { print “Number Is Not 5”;}
![Page 34: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/34.jpg)
Encapsulated Code
if ($number->equals(new Integer(5))) { print “Number Is 5”;} else { print “Number Is Not 5”;}
![Page 35: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/35.jpg)
Encapsulated Codeclass Decimal implements Number { protected $intValue; protected $exponent; public function equals(Number $a) { if ($a instanceof Decimal) { // Compare Directly } else { // Cast } }}
![Page 36: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/36.jpg)
Behavior Is Defined By The
API
![Page 37: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/37.jpg)
Two Types Of Primitive APIs
Interfaces (Explicit)
![Page 38: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/38.jpg)
Two Types Of Primitive APIs
Interfaces (Explicit)
Duck Typing (Implicit)
![Page 39: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/39.jpg)
If an Object Is A Collection Of Behaviors...
![Page 40: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/40.jpg)
What Is A Collection Of
Classes/Objects?
![Page 41: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/41.jpg)
APIs
Method
![Page 42: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/42.jpg)
APIs
Method MethodMethod
Class
![Page 43: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/43.jpg)
APIs
Method MethodMethod
Class ClassClass
Package
![Page 44: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/44.jpg)
APIs
Method MethodMethod
Class ClassClass
Package PackagePackage
Library
![Page 45: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/45.jpg)
APIs
Method MethodMethod
Class ClassClass
Package PackagePackage
Library
Framework
LibraryLibrary
![Page 46: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/46.jpg)
![Page 47: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/47.jpg)
What Makes A Good API?
![Page 48: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/48.jpg)
A Good APIDoes One Thing
![Page 49: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/49.jpg)
A Good APINever Changes
![Page 50: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/50.jpg)
A Good APIBehaves Like Its
Contract
![Page 51: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/51.jpg)
A Good APIHas A Narrow Responsibility
![Page 52: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/52.jpg)
A Good APIDepends Upon Abstractions
![Page 53: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/53.jpg)
And That’sSOLIDCode
![Page 54: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/54.jpg)
S - Single Responsibility Principle O- L - I - D-
A Good API Does One
Thing
![Page 55: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/55.jpg)
![Page 56: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/56.jpg)
S - Single Responsibility Principle O- Open / Closed Principle
L - I - D-
A Good API Never Changes
![Page 57: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/57.jpg)
![Page 58: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/58.jpg)
S - Single Responsibility Principle O- Open / Closed Principle
L - Liskov Substitution Principle
I - D-
A Good API Behaves Like Its Contract
![Page 59: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/59.jpg)
![Page 60: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/60.jpg)
![Page 61: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/61.jpg)
![Page 62: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/62.jpg)
S - Single Responsibility Principle O- Open / Closed Principle
L - Liskov Substitution Principle
I - Interface Segregation Principle
D-
A Good API Has A Narrow Responsibility
![Page 63: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/63.jpg)
![Page 64: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/64.jpg)
S - Single Responsibility Principle O- Open / Closed Principle
L - Liskov Substitution Principle
I - Interface Segregation Principle
D- Dependency Inversion Principle
A Good API Depends Upon Abstractions
![Page 65: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/65.jpg)
![Page 66: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/66.jpg)
S - Single Responsibility Principle O- Open / Closed Principle
L - Liskov Substitution Principle
I - Interface Segregation Principle
D- Dependency Inversion Principle
![Page 67: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/67.jpg)
Note That SOLID Does Not Dictate
What Is Good OOP
![Page 68: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/68.jpg)
SOLID Emerges From Good OOP
![Page 69: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/69.jpg)
![Page 70: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/70.jpg)
So, What Makes A Bad API?
![Page 71: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/71.jpg)
Global Variables(Spooky Action At A Distance)
![Page 72: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/72.jpg)
Depending OnSpecifics Of An Implementation
![Page 73: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/73.jpg)
Hidden Dependencies
![Page 74: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/74.jpg)
Unhealthy Focus On Performance
![Page 75: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/75.jpg)
Poorly Named APIs
![Page 76: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/76.jpg)
Duplication
![Page 77: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/77.jpg)
And That’sSTUPID
Code
![Page 78: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/78.jpg)
S - Singletons
T -U -P -I -D-
Global Variables(Spooky ActionAt A Distance)
![Page 79: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/79.jpg)
![Page 80: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/80.jpg)
S - Singletons
T - Tight Coupling
U -P -I -D-
Depending On Specifics Of An
Implementation
![Page 81: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/81.jpg)
![Page 82: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/82.jpg)
S - Singletons
T - Tight Coupling
U - Untestable Code
P -I -D-
Hidden Dependencies
![Page 83: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/83.jpg)
![Page 84: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/84.jpg)
S - Singletons
T - Tight Coupling
U - Untestable Code
P - Premature Optimization
I -D-
Unhealthy Focus On Performance
![Page 85: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/85.jpg)
![Page 86: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/86.jpg)
S - Singletons
T - Tight Coupling
U - Untestable Code
P - Premature Optimization
I - Indescriptive Naming
D-
Poorly Named APIs
![Page 87: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/87.jpg)
![Page 88: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/88.jpg)
S - Singletons
T - Tight Coupling
U - Untestable Code
P - Premature Optimization
I - Indescriptive Naming
D- Duplication
Duplication
Duplication
DuplicationDuplication
Duplication
DuplicationDuplication
Duplication
![Page 89: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/89.jpg)
![Page 90: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/90.jpg)
S - Singletons
T - Tight Coupling
U - Untestable Code
P - Premature Optimization
I - Indescriptive Naming
D- Duplication
![Page 91: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/91.jpg)
STUPID Embodies
Lessons Learned From Bad OOP
![Page 92: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/92.jpg)
What Good OOP Gives You
Modular CodeReusable CodeExtendable CodeEasy To Read CodeMaintainable CodeEasy To Change CodeEasy To Understand CodeClean Abstractions (mostly)
![Page 93: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/93.jpg)
What Good OOP Costs You
Tends To Have More “Layers”Tends To Be Slower At RuntimeTends To Have Larger CodebasesTends To Result In Over-AbstractionTends To Require More Effort To WriteTends To Require More Tacit Knowledge
![Page 94: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/94.jpg)
Let’s Look At Some Code!
![Page 95: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/95.jpg)
interface Car {
public function turnLeft(); public function turnRight(); public function goFaster(); public function goSlower(); public function shiftUp(); public function shiftDown(); public function start();
}
![Page 96: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/96.jpg)
interface Steerable { public function steer($angle);}interface Acceleratable { public function accelerate($amt);}interface Shiftable { public function shiftDown(); public function shiftUp();}
![Page 97: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/97.jpg)
interface Transmission { public function getNumberOfGears(); public function getGear(); public function shiftToNeutral(); public function shiftToReverse(); public function shiftToGear($gear);}interface Manual extends Transmission { public function engageClutch(); public function releaseClutch();}interface Automatic extends Transmission { public function shiftToDrive();}
![Page 98: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/98.jpg)
Principle Of
GoodEnough
![Page 99: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/99.jpg)
![Page 100: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/100.jpg)
![Page 101: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/101.jpg)
![Page 102: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/102.jpg)
![Page 103: Don't be STUPID, Grasp SOLID - North East PHP](https://reader034.vdocuments.site/reader034/viewer/2022051608/540df17e8d7f72767e8b4bd3/html5/thumbnails/103.jpg)