Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SOLID/STUPID
Search
GBProd
February 20, 2017
Programming
0
300
SOLID/STUPID
Base de cours autour des principes SOLID et STUPID
GBProd
February 20, 2017
Tweet
Share
More Decks by GBProd
See All by GBProd
Les tests en Symfony
gbprod
0
190
Make task runners great again
gbprod
2
310
Gilles, craftman from father to son
gbprod
0
110
DDD: Retour d'expérience
gbprod
0
33
Artisan développeur
gbprod
0
53
Other Decks in Programming
See All in Programming
Go の GC の不得意な部分を克服したい
taiyow
2
760
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
270
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
260
103 Early Hints
sugi_0000
1
220
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
180
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
Refactor your code - refactor yourself
xosofox
1
250
バグを見つけた?それAppleに直してもらおう!
uetyo
0
170
急成長期の品質とスピードを両立するフロントエンド技術基盤
soarteclab
0
920
Full stack testing :: basic to basic
up1
1
930
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
328
21k
Code Reviewing Like a Champion
maltzj
520
39k
The Pragmatic Product Professional
lauravandoore
32
6.3k
A Philosophy of Restraint
colly
203
16k
Side Projects
sachag
452
42k
KATA
mclloyd
29
14k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
A better future with KSS
kneath
238
17k
Site-Speed That Sticks
csswizardry
2
190
Transcript
STUPID Code ! Make it SOLID
STUPID Code ! Make it SOLID
Principles, not laws
You’re code is STUPID !
S T U P I D
S T U P I D ingleton
Global State
Hidden dependencies
But not impossible Difficult to test
S T U P I D ight coupling
Interaction level between components
Difficult to change
Difficult to reuse
Difficult to test
Avoiding “new”
S T U P I D ntestability
Everything must be easy to test
If you can’t test, the problem is about design
S T U P I D remature Optimization
Premature optimization is the root of all evil
Optimize only if it’s necessary
Optimize timely
Don’t do it (yet) !
Readability > Optimization
S T U P I D ndescriptive naming
Name properly
Names came from your domain
Don’t abbreviate
Don’t prefix/suffix
The length of a variable name should be proportional to
its scope. The length of a function or class name is the inverse.
“You should name a variable using the same care with
which you name a first-born child.”
Programming languages are for humans, not for computers
Code > Comments
Code = How
Tests = What
Comments = Why
S T U P I Duplication
Be lazy Don’t Repeat Yourself
Be lazy Don’t Repeat Yourself
Most of time Copy/Paste is bad
Use a Copy/Paste Detector
Make it SOLID plz !
S O L I D
S O L I D ingle responsability
Every class should have a single responsibility
Never be more than one reason for a class to
change
God classes
Don’t make your controller be God Objects
Avoid Mutators
Ask yourself what is class responsablity
Keep it as small as possible
S O L I D pen/Close
Open for extension, but closed for modification
extend > modify
setup > modify
S O L I D iskov substitution
Objects should be replaceable with instances of their subtypes without
altering the correctness of the program.
A square is NOT a rectangle
The mouse case
S O L I D nterface segregation
Many clients > One Generic Client
Don’t over-interface
S O L I Dependency injection
High level modules should not depend on low level modules.
Both should depend on abstractions.
Abstractions should not depend on details. Details should depend on
abstractions.
Be pragmatic
Exercice
git clone https://github.com/gbprod/solid-stupid.git