SOLID design Five design principles SOLID design 1
Description: SOLID design Five design principles SOLID design 1 SOLID, what is it? Single responsibility principle A class should have only a SINGLE responsibility Change in the specification on that responsibility should only affect this class
Related Topics
Download Presentation
"SOLID design Five design principles SOLID design 1" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Presentation Transcript
slide1. SOLID design Five design principles SOLID design 1<br>
slide2. SOLID, what is it? Single responsibility principle
A class should have only a SINGLE responsibility
Change in the specification on that responsibility should only affect this class
Open/close principle
Each class should be open for extensions (sub-classes), but closed for modifications
We should never need to modify an existing class
Liskov substitution principle
Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
Named after Barbara Liskov
Interface segregation principle
Many client-specific interfaces is better than one general purpose interface
Dependency inversion principle
Depend on abstractions, not on concretions SOLID design 2<br>
slide3. SOLID, what is it used for? The SOLID principles are used as a guideline
Designing systems
Refactoring systems
Detecting “smells” in code
Refactor until the code is SOLID SOLID design 3<br>
slide4. Single responsibility principle Based on cohesion
A class should do only one thing
Separation of concerns SOLID design 4<br>
slide5. Open/close principle Open for extensions
Sub-classes
Closed for modifications
New functionality should be placed in sub-classes
Overriding methods from the base class SOLID design 5<br>
slide6. Interface segregation principle Many client-specific interfaces is better than one general purpose interface
Clients should not be forced to depend upon interfaces that they don't use SOLID design 6<br>
slide7. Dependency inversion principle Depend on abstractions, not concretions
Abstractions = interfaces
Concretions = classes
Loose coupling Figure from Robert C. Martin http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf SOLID design 7<br>
slide8. References and further readings Robert C. Martin Design Principles and Design Patterns, 2000
http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf
michas The S.O.L.I.D Object Oriented Programming (OOP) Principles, 2010
http://www.codeproject.com/Articles/60845/The-S-O-L-I-D-Object-Oriented-Programming-OOP-Prin
Design Principles
http://www.oodesign.com/design-principles.html SOLID design 8<br>
slide2. SOLID, what is it? Single responsibility principle
A class should have only a SINGLE responsibility
Change in the specification on that responsibility should only affect this class
Open/close principle
Each class should be open for extensions (sub-classes), but closed for modifications
We should never need to modify an existing class
Liskov substitution principle
Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
Named after Barbara Liskov
Interface segregation principle
Many client-specific interfaces is better than one general purpose interface
Dependency inversion principle
Depend on abstractions, not on concretions SOLID design 2<br>
slide3. SOLID, what is it used for? The SOLID principles are used as a guideline
Designing systems
Refactoring systems
Detecting “smells” in code
Refactor until the code is SOLID SOLID design 3<br>
slide4. Single responsibility principle Based on cohesion
A class should do only one thing
Separation of concerns SOLID design 4<br>
slide5. Open/close principle Open for extensions
Sub-classes
Closed for modifications
New functionality should be placed in sub-classes
Overriding methods from the base class SOLID design 5<br>
slide6. Interface segregation principle Many client-specific interfaces is better than one general purpose interface
Clients should not be forced to depend upon interfaces that they don't use SOLID design 6<br>
slide7. Dependency inversion principle Depend on abstractions, not concretions
Abstractions = interfaces
Concretions = classes
Loose coupling Figure from Robert C. Martin http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf SOLID design 7<br>
slide8. References and further readings Robert C. Martin Design Principles and Design Patterns, 2000
http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf
michas The S.O.L.I.D Object Oriented Programming (OOP) Principles, 2010
http://www.codeproject.com/Articles/60845/The-S-O-L-I-D-Object-Oriented-Programming-OOP-Prin
Design Principles
http://www.oodesign.com/design-principles.html SOLID design 8<br>