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
150
DDD: Retour d'expérience
gbprod
0
39
Artisan développeur
gbprod
0
59
Other Decks in Programming
See All in Programming
PHPUnitの限界をPlaywrightで補完するテストアプローチ
yuzneri
0
370
NEWT Backend Evolution
xpromx
1
170
Strands Agents で実現する名刺解析アーキテクチャ
omiya0555
1
110
AIに安心して任せるためにTypeScriptで一意な型を作ろう
arfes0e2b3c
0
330
バイブコーディング超えてバイブデプロイ〜CloudflareMCPで実現する、未来のアプリケーションデリバリー〜
azukiazusa1
3
780
Dart 参戦!!静的型付き言語界の隠れた実力者
kno3a87
0
160
React は次の10年を生き残れるか:3つのトレンドから考える
oukayuka
41
16k
LLMは麻雀を知らなすぎるから俺が教育してやる
po3rin
3
1.9k
テスターからテストエンジニアへ ~新米テストエンジニアが歩んだ9ヶ月振り返り~
non0113
2
250
中級グラフィックス入門~効率的なメッシュレット描画~
projectasura
4
2.4k
新しいモバイルアプリ勉強会(仮)について
uetyo
1
250
Terraform やるなら公式スタイルガイドを読もう 〜重要項目 10選〜
hiyanger
11
2.8k
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
The World Runs on Bad Software
bkeepers
PRO
70
11k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
50
5.5k
Site-Speed That Sticks
csswizardry
10
750
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
790
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.8k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
The Pragmatic Product Professional
lauravandoore
36
6.8k
How to train your dragon (web standard)
notwaldorf
96
6.1k
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