×
Copy
Open
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
STUPID Code ! Make it SOLID
Slide 2
Slide 2 text
STUPID Code ! Make it SOLID
Slide 3
Slide 3 text
Principles, not laws
Slide 4
Slide 4 text
You’re code is STUPID !
Slide 5
Slide 5 text
S T U P I D
Slide 6
Slide 6 text
S T U P I D ingleton
Slide 7
Slide 7 text
Global State
Slide 8
Slide 8 text
Hidden dependencies
Slide 9
Slide 9 text
But not impossible Difficult to test
Slide 10
Slide 10 text
S T U P I D ight coupling
Slide 11
Slide 11 text
Interaction level between components
Slide 12
Slide 12 text
Difficult to change
Slide 13
Slide 13 text
Difficult to reuse
Slide 14
Slide 14 text
Difficult to test
Slide 15
Slide 15 text
Avoiding “new”
Slide 16
Slide 16 text
S T U P I D ntestability
Slide 17
Slide 17 text
Everything must be easy to test
Slide 18
Slide 18 text
If you can’t test, the problem is about design
Slide 19
Slide 19 text
S T U P I D remature Optimization
Slide 20
Slide 20 text
Premature optimization is the root of all evil
Slide 21
Slide 21 text
Optimize only if it’s necessary
Slide 22
Slide 22 text
Optimize timely
Slide 23
Slide 23 text
Don’t do it (yet) !
Slide 24
Slide 24 text
Readability > Optimization
Slide 25
Slide 25 text
S T U P I D ndescriptive naming
Slide 26
Slide 26 text
Name properly
Slide 27
Slide 27 text
Names came from your domain
Slide 28
Slide 28 text
Don’t abbreviate
Slide 29
Slide 29 text
Don’t prefix/suffix
Slide 30
Slide 30 text
The length of a variable name should be proportional to its scope. The length of a function or class name is the inverse.
Slide 31
Slide 31 text
“You should name a variable using the same care with which you name a first-born child.”
Slide 32
Slide 32 text
Programming languages are for humans, not for computers
Slide 33
Slide 33 text
Code > Comments
Slide 34
Slide 34 text
Code = How
Slide 35
Slide 35 text
Tests = What
Slide 36
Slide 36 text
Comments = Why
Slide 37
Slide 37 text
S T U P I Duplication
Slide 38
Slide 38 text
Be lazy Don’t Repeat Yourself
Slide 39
Slide 39 text
Be lazy Don’t Repeat Yourself
Slide 40
Slide 40 text
Most of time Copy/Paste is bad
Slide 41
Slide 41 text
Use a Copy/Paste Detector
Slide 42
Slide 42 text
Make it SOLID plz !
Slide 43
Slide 43 text
S O L I D
Slide 44
Slide 44 text
S O L I D ingle responsability
Slide 45
Slide 45 text
Every class should have a single responsibility
Slide 46
Slide 46 text
Never be more than one reason for a class to change
Slide 47
Slide 47 text
God classes
Slide 48
Slide 48 text
Don’t make your controller be God Objects
Slide 49
Slide 49 text
Avoid Mutators
Slide 50
Slide 50 text
Ask yourself what is class responsablity
Slide 51
Slide 51 text
Keep it as small as possible
Slide 52
Slide 52 text
S O L I D pen/Close
Slide 53
Slide 53 text
Open for extension, but closed for modification
Slide 54
Slide 54 text
extend > modify
Slide 55
Slide 55 text
setup > modify
Slide 56
Slide 56 text
S O L I D iskov substitution
Slide 57
Slide 57 text
Objects should be replaceable with instances of their subtypes without altering the correctness of the program.
Slide 58
Slide 58 text
A square is NOT a rectangle
Slide 59
Slide 59 text
The mouse case
Slide 60
Slide 60 text
S O L I D nterface segregation
Slide 61
Slide 61 text
Many clients > One Generic Client
Slide 62
Slide 62 text
Don’t over-interface
Slide 63
Slide 63 text
S O L I Dependency injection
Slide 64
Slide 64 text
High level modules should not depend on low level modules. Both should depend on abstractions.
Slide 65
Slide 65 text
Abstractions should not depend on details. Details should depend on abstractions.
Slide 66
Slide 66 text
Be pragmatic
Slide 67
Slide 67 text
Exercice
Slide 68
Slide 68 text
git clone https://github.com/gbprod/solid-stupid.git