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
360
0
Share
SOLID/STUPID
Base de cours autour des principes SOLID et STUPID
GBProd
February 20, 2017
More Decks by GBProd
See All by GBProd
Les tests en Symfony
gbprod
0
240
Make task runners great again
gbprod
2
330
Gilles, craftman from father to son
gbprod
0
180
DDD: Retour d'expérience
gbprod
0
48
Artisan développeur
gbprod
0
70
Other Decks in Programming
See All in Programming
Inspired By RubyKaigi (EN)
atzzcokek
0
460
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
2
1k
Oxcを導入して開発体験が向上した話
yug1224
4
260
OSもどきOS
arkw
0
350
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
400
プロパティの順序で型推論が壊れる!? TypeScript6.0の修正からContext-Sensitivityの仕組みを追う
bicstone
2
1.3k
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
7
2.4k
CLIであることを活かしたGitHub Copilot CLI活用術 / GitHub Copilot CLI Pro Tips & Tricks
nao_mk2
1
1.2k
Oxlintのカスタムルールの現況
syumai
5
920
新規プロダクトを高速で生み出すハーネスエンジニアリング
seanchas116
18
7.6k
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
1.1k
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
250
Featured
See All Featured
How to build a perfect <img>
jonoalderson
1
5.5k
RailsConf 2023
tenderlove
30
1.5k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
170
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
380
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Into the Great Unknown - MozCon
thekraken
41
2.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
22k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
420
Ruling the World: When Life Gets Gamed
codingconduct
0
240
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
Optimising Largest Contentful Paint
csswizardry
37
3.7k
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