Upload
codecampiasi
View
551
Download
0
Embed Size (px)
DESCRIPTION
Citation preview
Scratching SOLID
IULIAN TANASESCU-VLAD
10 / 03 / 2012
So … what is SOLID?
Five basic principles of object-oriented programming and design.
Single responsibility principle
Open/closed principle
Liskov substitution principle
Interface segregation principle
Dependency inversion principle
Who put them together?
What do you know … it's Uncle Bob!
Robert C. Martin http://objectmentor.com/omTeam/martin_r.html
SRP
SRP
Every object should have a single responsibility and that responsibility should be entirely encapsulated by the class.
Wikipedia
Responsibility!? … not again
Ah … a reason to change
SRP
“a measure of how strongly-related or focused the responsibilities of a single module are”
COHESION!
OCP
OCP
Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.
Wikipedia
Open and closed … another paradox!?
New functionality can be added as new requirements are generated.
Never modify the code except to correct bugs.
OCP
LSP
LSP
If S is a subtype of T, then objects of type T may be replaced with objects of type S without altering any of the desirable properties of that program (correctness, task performed, etc.)
Wikipedia
That sounds so ... formal!
Code that uses a base class must be able to substitute it with a subclass without knowing it.
ISP
ISP
Once an interface has become too 'fat' it needs to be split into smaller and more specific interfaces.
Wikipedia
Why!?
COHESION!
No client should be forced to depend on methods it does not use.
DIP
DIP
A. High-level modules should not depend on low-level modules. Both should depend on abstractions.B. Abstractions should not depend upon details. Details should depend upon abstractions.
Wikipedia
DIP
“a degree to which each program module relies on each one of the other modules”
COUPLING!
Please fill in the evaluation forms
Thank you!