$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SOLID/STUPID
Search
GBProd
February 20, 2017
Programming
0
340
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
160
DDD: Retour d'expérience
gbprod
0
42
Artisan développeur
gbprod
0
63
Other Decks in Programming
See All in Programming
CSC305 Lecture 17
javiergs
PRO
0
270
All(?) About Point Sets
hole
0
260
251126 TestState APIってなんだっけ?Step Functionsテストどう変わる?
east_takumi
0
300
無秩序からの脱却 / Emergence from chaos
nrslib
2
12k
【Streamlit x Snowflake】データ基盤からアプリ開発・AI活用まで、すべてをSnowflake内で実現
ayumu_yamaguchi
1
110
AIコードレビューがチームの"文脈"を 読めるようになるまで
marutaku
0
310
ZOZOにおけるAI活用の現在 ~モバイルアプリ開発でのAI活用状況と事例~
zozotech
PRO
8
4.1k
CSC509 Lecture 14
javiergs
PRO
0
220
関数の挙動書き換える
takatofukui
4
770
[堅牢.py #1] テストを書かない研究者に送る、最初にテストを書く実験コード入門 / Let's start your ML project by writing tests
shunk031
11
6.9k
ViewファーストなRailsアプリ開発のたのしさ
sugiwe
0
400
AIコーディングエージェント(skywork)
kondai24
0
120
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
How to train your dragon (web standard)
notwaldorf
97
6.4k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
The Cult of Friendly URLs
andyhume
79
6.7k
Balancing Empowerment & Direction
lara
5
780
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
Making the Leap to Tech Lead
cromwellryan
135
9.6k
A designer walks into a library…
pauljervisheath
210
24k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
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