solid software principles with c#
DESCRIPTION
A small talk I did on Solid PrinciplesTRANSCRIPT
SOLID Software Development
Ken Burkhardt
What is SOLID?
Single Responsibility Principle Open Closed Principle
Liskov Substitution PrincipleInterface Segregation PrincipleDependency Inversion Principle
Why SOLID?
S.O.L.I.D. is a collection of best-practice, object-oriented design
principles which can be applied to your design, allowing you to
accomplish various desirable goals such as loose-coupling, higher
maintainability
Single Responsibility Principle
THERE SHOULD NEVER BE MORE THAN ONE REASON FOR A CLASS TO
CHANGE.
Demo - Superclass
Open Closed Principle
SOFTWARE ENTITIES SHOULD BE OPEN FOR EXTENSION BUT CLOSED
FOR MODIFICATION
Demo – Add New Validator
Liskov Substitution Principle
You should be able to use any derived class in place of a parent class and have it behave in the same manner without modification. It ensures that a derived class does not affect the behavior of
the parent class, i.e. that a derived class must be substitutable for its base class.
Interface Segregation Principle
CLIENTS SHOULD NOT BE FORCED TO DEPEND UPON INTERFACES THAT
THEY DO NOT USE
Demo - Animals
Dependency Inversion Principle
A. HIGH LEVEL MODULES SHOULD NOT DEPEND UPON LOW LEVEL MODULES. BOTH SHOULD DEPEND UPON ABSTRACTIONS
B. ABSTRACTIONS SHOULD NOT DEPEND UPON DETAILS. DETAILS SHOULD DEPEND UPON ABSTRACTIONS
Bad designs and poor code is not good because it's hard to change. Bad designs are:
- Rigid (change affects too many parts of the system) - Fragile (every change breaks something unexpected) - Immobile (impossible to reuse)
Demo - Interfaces