2. SOLID
• Acronim of five principles
• Principles, not laws
• A bit vague or abstract
• They are all interelated
• A bit marketing oriented (ejem Uncle Bob ;) )
• A bit criticized
• By Michael Feathers or Robert Martin
18. Responsibilities to whom?
• Classes have responsibilities to their users, those users can be
classified into actors based on the roles that they play on the
application.
• A responsibility is a family of functions that serves a particular actor.
26. Open
Close
Principle
A software module should
be open for extension and
close for modification
Change a module
behaviour without
changing its source code
32. Liskov
substitution
Principle
If S is a subtype of T, then objects of type T
may be replaced with objects of type S
If the base class does something, the
inherited class must do it too and in a way
that doesn't violate the expectations of the
users of the base class
34. Simptoms
• Inherited class with empty methods that are implemented in the base
class
• Inherited class with that throw exceptinos
• Check If typeof (x) on the base class
42. Interface
Segregation
Principle
No client should be forced to depend
on methods it does not use
Interfaces have more to do with the
classes that use them than with the
classes that implement them
60. 4 rules of simple design
• Passes the tests
• Reveals intention
• No duplication
• Fewest elements
61. TRUE
• Transparent: The consequence of change should be obvious in the
code that is changing and in distant code that relies upon it
• Reasonable: The cost of any change should be proportional to the
benefits the change achieves
• Usable: The code should be usable in new and unexpected contexs
• Exemplary: The code itself should encourage those that use it to
perpetuate those qualities