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
330
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
220
Make task runners great again
gbprod
2
320
Gilles, craftman from father to son
gbprod
0
140
DDD: Retour d'expérience
gbprod
0
39
Artisan développeur
gbprod
0
59
Other Decks in Programming
See All in Programming
git worktree × Claude Code × MCP ~生成AI時代の並列開発フロー~
hisuzuya
1
450
GoのGenericsによるslice操作との付き合い方
syumai
3
680
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
46
30k
Beyond Portability: Live Migration for Evolving WebAssembly Workloads
chikuwait
0
390
設計やレビューに悩んでいるPHPerに贈る、クリーンなオブジェクト設計の指針たち
panda_program
6
1.3k
A2A プロトコルを試してみる
azukiazusa1
2
1.1k
Result型で“失敗”を型にするPHPコードの書き方
kajitack
4
310
Cursor AI Agentと伴走する アプリケーションの高速リプレイス
daisuketakeda
1
130
[初登壇@jAZUG]アプリ開発者が気になるGoogleCloud/Azure+wasm/wasi
asaringo
0
130
PHPで始める振る舞い駆動開発(Behaviour-Driven Development)
ohmori_yusuke
2
180
AIエージェントはこう育てる - GitHub Copilot Agentとチームの共進化サイクル
koboriakira
0
350
技術同人誌をMCP Serverにしてみた
74th
0
290
Featured
See All Featured
Building an army of robots
kneath
306
45k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
700
Embracing the Ebb and Flow
colly
86
4.7k
GitHub's CSS Performance
jonrohan
1031
460k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
Six Lessons from altMBA
skipperchong
28
3.8k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Facilitating Awesome Meetings
lara
54
6.4k
The Cost Of JavaScript in 2023
addyosmani
51
8.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
A better future with KSS
kneath
239
17k
Music & Morning Musume
bryan
46
6.6k
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