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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
GBProd
February 20, 2017
Programming
0
350
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
230
Make task runners great again
gbprod
2
330
Gilles, craftman from father to son
gbprod
0
170
DDD: Retour d'expérience
gbprod
0
44
Artisan développeur
gbprod
0
64
Other Decks in Programming
See All in Programming
どんと来い、データベース信頼性エンジニアリング / Introduction to DBRE
nnaka2992
1
280
コードレビューをしない選択 #でぃーぷらすトウキョウ
kajitack
3
900
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
140
メタプログラミングで実現する「コードを仕様にする」仕組み/nikkei-tech-talk43
nikkei_engineer_recruiting
0
180
Ruby and LLM Ecosystem 2nd
koic
1
580
ポーリング処理廃止によるイベント駆動アーキテクチャへの移行
seitarof
3
1k
AHC061解説
shun_pi
0
360
RAGでハマりがちな"Excelの罠"を、データの構造化で突破する
harumiweb
9
2.8k
オブザーバビリティ駆動開発って実際どうなの?
yohfee
3
830
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
13
8k
Windows on Ryzen and I
seosoft
0
260
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
840
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
170
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
180
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.1k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.4k
The Spectacular Lies of Maps
axbom
PRO
1
620
Un-Boring Meetings
codingconduct
0
220
Building AI with AI
inesmontani
PRO
1
790
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
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