SlideShare a Scribd company logo
February 18, 2016
S.O.L.I.D Development Principles
Object oriented design best practices
“It is not the beauty of a building you should look at; its the construction of the
foundation that will stand the test of time.” - David Allan Coe
Presentation by: Aniket Gadre
Presented by Agency Oasis
Slide 2
What is SOLID?
Single-responsibility principle (SRP)
Open-closed principle (OCP)
Liskov substitution principle (LSP)
Interface segregation principle (ISP)
Dependency Inversion Principle (DIP)
Presented by Agency Oasis
Slide 3
Why SOLID?
• Principled way of managing dependencies
especially in a large application
• Loose coupling (degree of interdependence
between software modules)
• More cohesion (degree to which the
elements of a module belong together)
• Code is more reusable, robust, flexible,
testable and maintainable
Presented by Agency Oasis
Slide 4
Single Responsibility Principle (SRP)
Formal Definition: A class should have
one and only one reason to change
(single responsibility)”
Simple Definition: Do not burden one
class with too many responsibilities.
Presented by Agency Oasis
Slide 5
Benefits of SRP
• Code complexity is reduced
• Readability is greatly improved
• Coupling is generally reduced
• Your code has a better chance of cleanly evolving
Presented by Agency Oasis
Slide 6
Open Closed Principle (OCP)
Formal Definition: Entities (classes,
functions etc.) should be open for
extension but closed for modifications
Simple Definition: You should be able to
extend a class’s behavior, without
modifying it.
My definition: Ideally, once a class is
done, it’s done.
Presented by Agency Oasis
Slide 7
Benefits of OCP
• Easy to extend code based on new requirements
• Easier to test only the new functionality
• More maintainable code
• Fewer bugs since existing functionality is intact
Presented by Agency Oasis
Slide 8
Liskov Substitution Principle (LSP)
Formal Definition: Objects in a program
should be replaceable with instances of
their subtypes without altering the
correctness of that program.
Can someone explain in simple words?
Presented by Agency Oasis
Slide 9
LISKOV’s Substitution Principle continued…
“Let q(x) be a property provable about objects x of type T. Then q(y) should be
provable for objects of y of type S where S in a sub-type of T”
Simple Definition: Objects of the derived class must behave in a manner
consistent with the promises made in the base class' contract.“
My definition: All derived classes should be exact sub-types of the base class NOT
kind of sub-types.
Presented by Agency Oasis
Slide 10
Benefits of LSP
• Extension of Open/Closed principle
• Code reusability
• Reduced coupling
• Derived classes need not implement the methods
they don’t need
• Helps in code maintenance
Presented by Agency Oasis
Slide 11
Interface Segregation Principle (ISP)
Formal Definition: Many client-specific
interfaces are better than one general
purpose interface.
Simple Definition: Clients should not be
forced to implement interfaces they do not
use.
My definition: Break down a large class into
smaller manageable interfaces
Presented by Agency Oasis
Slide 12
Benefits of ISP
• Flexible design
• Easy to extend the functionality
• More maintainable code in small chunks
• Clients not forced to implement methods
they don’t need
Ex: Membership Provider
Presented by Agency Oasis
Slide 13
Dependency Inversion Principle (DIP)
Formal Definition: Entities must
depend on abstractions not on
concretions.”
Simple Definition: High level module
must not depend on the low level
module, but they should depend on
abstractions.
My definition: Anytime I new up a class
it’s time to look at DIP
Presented by Agency Oasis
Slide 14
Benefits of DIP
• Loose coupling
• More plug and play type functionality
• Mockable and testable
• More reusable code
Presented by Agency Oasis
Slide 15
To SOLID or not to SOLID – That is the question?
• Over engineering/Premature optimization
• Readability
• Debatable
• Lines of code
Presented by Agency Oasis
Slide 16
QUESTIONS?
Presented by Agency Oasis
February 18, 2016
Helpful links
https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)
http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
https://channel9.msdn.com/Events/TechEd/Europe/2014/DEV-B210
Presented by Agency Oasis

More Related Content

Similar to Solid-Principles

Inversion of Control
Inversion of ControlInversion of Control
Inversion of Control
Shuhab Tariq
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1
Julie Iskander
 
Software design principles for evolving architectures
Software design principles for evolving architecturesSoftware design principles for evolving architectures
Software design principles for evolving architectures
Firat Atagun
 
Software design principles
Software design principlesSoftware design principles
Software design principles
Md.Mojibul Hoque
 
SOLID Software Principles with C#
SOLID Software Principles with C#SOLID Software Principles with C#
SOLID Software Principles with C#
Ken Burkhardt
 
S.O.L.I.D. principles of software development
S.O.L.I.D. principles of software developmentS.O.L.I.D. principles of software development
S.O.L.I.D. principles of software development
AmanSoni129
 
Object Oriented Programming Ch3 SRP, DIP, ISP
Object Oriented Programming Ch3 SRP, DIP, ISPObject Oriented Programming Ch3 SRP, DIP, ISP
Object Oriented Programming Ch3 SRP, DIP, ISP
Chihyang Li
 
Dependency Injection in .NET
Dependency Injection in .NETDependency Injection in .NET
Dependency Injection in .NET
ssusere19c741
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and Patterns
Juan Lopez
 
Solid principles
Solid principlesSolid principles
Solid principles
Kumaresh Chandra Baruri
 
Software Design Principles
Software Design PrinciplesSoftware Design Principles
Software Design Principles
Ocean Dong
 
OO Design Principles
OO Design PrinciplesOO Design Principles
OO Design Principles
Anju Kanjirathingal
 
SOLID
SOLIDSOLID
Design principle vs design patterns
Design principle vs design patternsDesign principle vs design patterns
Design principle vs design patterns
Prabhakar Sharma
 
Refactoring to SOLID Code
Refactoring to SOLID CodeRefactoring to SOLID Code
Refactoring to SOLID Code
Adil Mughal
 
Solid principle
Solid principleSolid principle
Solid principle
muhammadali0014
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
Basavaraj Patil
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
deonpmeyer
 
Solid principles
Solid principlesSolid principles
Solid principles
Monica Rodrigues
 
Is your code solid
Is your code solidIs your code solid
Is your code solid
Nathan Gloyn
 

Similar to Solid-Principles (20)

Inversion of Control
Inversion of ControlInversion of Control
Inversion of Control
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1
 
Software design principles for evolving architectures
Software design principles for evolving architecturesSoftware design principles for evolving architectures
Software design principles for evolving architectures
 
Software design principles
Software design principlesSoftware design principles
Software design principles
 
SOLID Software Principles with C#
SOLID Software Principles with C#SOLID Software Principles with C#
SOLID Software Principles with C#
 
S.O.L.I.D. principles of software development
S.O.L.I.D. principles of software developmentS.O.L.I.D. principles of software development
S.O.L.I.D. principles of software development
 
Object Oriented Programming Ch3 SRP, DIP, ISP
Object Oriented Programming Ch3 SRP, DIP, ISPObject Oriented Programming Ch3 SRP, DIP, ISP
Object Oriented Programming Ch3 SRP, DIP, ISP
 
Dependency Injection in .NET
Dependency Injection in .NETDependency Injection in .NET
Dependency Injection in .NET
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and Patterns
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Software Design Principles
Software Design PrinciplesSoftware Design Principles
Software Design Principles
 
OO Design Principles
OO Design PrinciplesOO Design Principles
OO Design Principles
 
SOLID
SOLIDSOLID
SOLID
 
Design principle vs design patterns
Design principle vs design patternsDesign principle vs design patterns
Design principle vs design patterns
 
Refactoring to SOLID Code
Refactoring to SOLID CodeRefactoring to SOLID Code
Refactoring to SOLID Code
 
Solid principle
Solid principleSolid principle
Solid principle
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Is your code solid
Is your code solidIs your code solid
Is your code solid
 

Solid-Principles

  • 1. February 18, 2016 S.O.L.I.D Development Principles Object oriented design best practices “It is not the beauty of a building you should look at; its the construction of the foundation that will stand the test of time.” - David Allan Coe Presentation by: Aniket Gadre Presented by Agency Oasis
  • 2. Slide 2 What is SOLID? Single-responsibility principle (SRP) Open-closed principle (OCP) Liskov substitution principle (LSP) Interface segregation principle (ISP) Dependency Inversion Principle (DIP) Presented by Agency Oasis
  • 3. Slide 3 Why SOLID? • Principled way of managing dependencies especially in a large application • Loose coupling (degree of interdependence between software modules) • More cohesion (degree to which the elements of a module belong together) • Code is more reusable, robust, flexible, testable and maintainable Presented by Agency Oasis
  • 4. Slide 4 Single Responsibility Principle (SRP) Formal Definition: A class should have one and only one reason to change (single responsibility)” Simple Definition: Do not burden one class with too many responsibilities. Presented by Agency Oasis
  • 5. Slide 5 Benefits of SRP • Code complexity is reduced • Readability is greatly improved • Coupling is generally reduced • Your code has a better chance of cleanly evolving Presented by Agency Oasis
  • 6. Slide 6 Open Closed Principle (OCP) Formal Definition: Entities (classes, functions etc.) should be open for extension but closed for modifications Simple Definition: You should be able to extend a class’s behavior, without modifying it. My definition: Ideally, once a class is done, it’s done. Presented by Agency Oasis
  • 7. Slide 7 Benefits of OCP • Easy to extend code based on new requirements • Easier to test only the new functionality • More maintainable code • Fewer bugs since existing functionality is intact Presented by Agency Oasis
  • 8. Slide 8 Liskov Substitution Principle (LSP) Formal Definition: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program. Can someone explain in simple words? Presented by Agency Oasis
  • 9. Slide 9 LISKOV’s Substitution Principle continued… “Let q(x) be a property provable about objects x of type T. Then q(y) should be provable for objects of y of type S where S in a sub-type of T” Simple Definition: Objects of the derived class must behave in a manner consistent with the promises made in the base class' contract.“ My definition: All derived classes should be exact sub-types of the base class NOT kind of sub-types. Presented by Agency Oasis
  • 10. Slide 10 Benefits of LSP • Extension of Open/Closed principle • Code reusability • Reduced coupling • Derived classes need not implement the methods they don’t need • Helps in code maintenance Presented by Agency Oasis
  • 11. Slide 11 Interface Segregation Principle (ISP) Formal Definition: Many client-specific interfaces are better than one general purpose interface. Simple Definition: Clients should not be forced to implement interfaces they do not use. My definition: Break down a large class into smaller manageable interfaces Presented by Agency Oasis
  • 12. Slide 12 Benefits of ISP • Flexible design • Easy to extend the functionality • More maintainable code in small chunks • Clients not forced to implement methods they don’t need Ex: Membership Provider Presented by Agency Oasis
  • 13. Slide 13 Dependency Inversion Principle (DIP) Formal Definition: Entities must depend on abstractions not on concretions.” Simple Definition: High level module must not depend on the low level module, but they should depend on abstractions. My definition: Anytime I new up a class it’s time to look at DIP Presented by Agency Oasis
  • 14. Slide 14 Benefits of DIP • Loose coupling • More plug and play type functionality • Mockable and testable • More reusable code Presented by Agency Oasis
  • 15. Slide 15 To SOLID or not to SOLID – That is the question? • Over engineering/Premature optimization • Readability • Debatable • Lines of code Presented by Agency Oasis
  • 17. February 18, 2016 Helpful links https://en.wikipedia.org/wiki/SOLID_(object-oriented_design) http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod https://channel9.msdn.com/Events/TechEd/Europe/2014/DEV-B210 Presented by Agency Oasis