2. 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
3. Who put them together?
What do you know … it's Uncle Bob!
Robert C. Martin
http://objectmentor.com/omTeam/martin_r.html
5. 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
6. SRP
“a measure of how strongly-related or
focused the responsibilities of a single
module are”
COHESION!
8. 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.
11. 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.
13. 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.
15. 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
16. DIP
“a degree to which each program module
relies on each one of the other modules”
COUPLING!