SlideShare a Scribd company logo
1 of 63
SOLID Design
 Principles
What the heck is a principle?
What the heck is a principle?
Guideline for creating software
that stands up well to iterative
development
What the heck is a principle?
Guideline for creating software
that stands up well to iterative
development
Statements that can be made
about your code’s design
What the heck is a principle?
Guideline for creating software
that stands up well to iterative
development
Statements that can be made
about your code’s design

FSM avoidance
Why should I care?
Why should I care?
Uncle Bob Martin
Why should I care?
Uncle Bob Martin
    - Old Dude
Why should I care?
Uncle Bob Martin
    - Old Dude
    - Wrote tons of books
Why should I care?
Uncle Bob Martin
    - Old Dude
    - Wrote tons of books
    - Knows a thing or two about
     writing software
Why should I care?
Uncle Bob Martin
    - Old Dude
    - Wrote tons of books
    - Knows a thing or two about
     writing software

These things will make you
better codes
Why should I care?
Uncle Bob Martin
    - Old Dude
    - Wrote tons of books
    - Knows a thing or two about
     writing software

These things will make you
better codes

50% less   Y U NO!!!
Principles vs. Patterns
Principles vs. Patterns

Aren’t patterns enough?
Principles vs. Patterns

Aren’t patterns enough?

Who are you?
Principles vs. Patterns

Aren’t patterns enough?

Who are you?

SOLID Principles are the basis
for useful patterns
S.
O.
L.
I.
D.
S.
 Single Responsibility

O.
L.
I.
D.
S.
 Single Responsibility

O.
 Open / Closed


L.
I.
D.
S.
 Single Responsibility

O.
 Open / Closed


L.
 Liskov Substitution


I.
D.
S.
 Single Responsibility

O.
 Open / Closed


L.
 Liskov Substitution


I.
 Interface Segregation


D.
S.
 Single Responsibility

O.
 Open / Closed


L.
 Liskov Substitution


I.
 Interface Segregation


D.
 Dependency Inversion
Single Responsibility Principle
Single Responsibility Principle
an Object should only have one
“axis of change”
Single Responsibility Principle
an Object should only have one
“axis of change”

as software requirements shift,
refactoring is reflected through
changes of responsibility in your
code
Single Responsibility Principle
an Object should only have one
“axis of change”

as software requirements shift,
refactoring is reflected through
changes of responsibility in your
code

complex code only gets more
complex
Single Responsibility Principle
Single Responsibility Principle
anti-pattern: watch out for
large branching statements
Single Responsibility Principle
anti-pattern: watch out for
large branching statements

favor method simplicity
Single Responsibility Principle
anti-pattern: watch out for
large branching statements

favor method simplicity

should be apparent when practicing
TDD
Open/Closed Principle
Open/Closed Principle
“[objects] should be open for
extension, but closed for
modification”
Open/Closed Principle
“[objects] should be open for
extension, but closed for
modification”

makes code that’s more resilient
over time
Open/Closed Principle
“[objects] should be open for
extension, but closed for
modification”

makes code that’s more resilient
over time

very important for maintaining
large, production codebases
Open/Closed Principle
Open/Closed Principle

anti-pattern: modifying native
Prototypes in Javascript
Open/Closed Principle

anti-pattern: modifying native
Prototypes in Javascript

used and violated in Backbone.js
Open/Closed Principle

anti-pattern: modifying native
Prototypes in Javascript

used and violated in Backbone.js

test coverage alleviates some of
the pain that open/close want to
shield you from
Liskov Substitution
Liskov Substitution
derived types should be
completely substitutable from
their base types
Liskov Substitution
derived types should be
completely substitutable from
their base types

about preserving expectations when
creating classes and subclasses
Liskov Substitution
derived types should be
completely substitutable from
their base types

about preserving expectations when
creating classes and subclasses

Often this is a built in
language feature
Interface Segregation
Interface Segregation

favor many specific interfaces
over a single, “fat” interface
Interface Segregation

favor many specific interfaces
over a single, “fat” interface

an api should only contains the
methods its caller needs
Interface Segregation

favor many specific interfaces
over a single, “fat” interface

an api should only contains the
methods its caller needs

leading cause of FSM, tightly
coupled code
Interface Segregation
Interface Segregation

jQuery is written as a series of
separate interfaces with a
common core
Interface Segregation

jQuery is written as a series of
separate interfaces with a
common core

increases performance, sanity
Interface Segregation

jQuery is written as a series of
separate interfaces with a
common core

increases performance, sanity

“no client should be forced to
depend on code it does not use”
Interface Segregation

jQuery is written as a series of
separate interfaces with a
common core

increases performance, sanity

“no client should be forced to
depend on code it does not use”

another consequence of TDD
Dependency Inversion
Dependency Inversion
“depend on abstractions, not on
concretions.”
Dependency Inversion
“depend on abstractions, not on
concretions.”

create high-level software that is
decoupled from low-level software
through abstraction
Dependency Inversion
“depend on abstractions, not on
concretions.”

create high-level software that is
decoupled from low-level software
through abstraction

allows for saner, more flexible
resources
Dependency Inversion
Dependency Inversion
ActiveRecord allows Rails to
abstract database interface away
from users
Dependency Inversion
ActiveRecord allows Rails to
abstract database interface away
from users

Sizzle, $.ajax allows jQuery to
abstract low level DOM methods
What does it mean?
What does it mean?
You don’t create re-usable code
by accident.
What does it mean?
You don’t create re-usable code
by accident.

You experience these principles
every day
What does it mean?
You don’t create re-usable code
by accident.

You experience these principles
every day

Creates a good checklist of
“objective refactoring” statements
S.
 Single Responsibility

O.
 Open / Closed


L.
 Liskov Substitution


I.
 Interface Segregation


D.
 Dependency Inversion

More Related Content

What's hot

What's hot (20)

Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Clean code: SOLID
Clean code: SOLIDClean code: SOLID
Clean code: SOLID
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#
 
Solid principles
Solid principlesSolid principles
Solid principles
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
 
Solid design principles
Solid design principlesSolid design principles
Solid design principles
 
Geecon09: SOLID Design Principles
Geecon09: SOLID Design PrinciplesGeecon09: SOLID Design Principles
Geecon09: SOLID Design Principles
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
S.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsS.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software Architects
 
Liscov substitution principle
Liscov substitution principleLiscov substitution principle
Liscov substitution principle
 
principles of object oriented class design
principles of object oriented class designprinciples of object oriented class design
principles of object oriented class design
 
Dependency Inversion Principle
Dependency Inversion PrincipleDependency Inversion Principle
Dependency Inversion Principle
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design Principles
 
The Single Responsibility Principle
The Single Responsibility PrincipleThe Single Responsibility Principle
The Single Responsibility Principle
 
Dependency injection presentation
Dependency injection presentationDependency injection presentation
Dependency injection presentation
 
Open Close Principle
Open Close PrincipleOpen Close Principle
Open Close Principle
 

Viewers also liked

Present simple vs present continuous ppt
Present simple vs present continuous pptPresent simple vs present continuous ppt
Present simple vs present continuous ppt
katherlabra
 
"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design Principles"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design Principles
Serhiy Oplakanets
 

Viewers also liked (14)

Software Design principles
Software Design principlesSoftware Design principles
Software Design principles
 
Presentation on SOLID design principles
Presentation on SOLID design principlesPresentation on SOLID design principles
Presentation on SOLID design principles
 
Are You a SOLID Coder?
Are You a SOLID Coder?Are You a SOLID Coder?
Are You a SOLID Coder?
 
Solid Software Design Principles
Solid Software Design PrinciplesSolid Software Design Principles
Solid Software Design Principles
 
SOLID Principles part 1
SOLID Principles part 1SOLID Principles part 1
SOLID Principles part 1
 
Open Closed Principle kata
Open Closed Principle kataOpen Closed Principle kata
Open Closed Principle kata
 
The SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design PatternsThe SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design Patterns
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
 
Present Simple And Continuous
Present Simple And ContinuousPresent Simple And Continuous
Present Simple And Continuous
 
SOLID principles
SOLID principlesSOLID principles
SOLID principles
 
Present simple vs present continuous ppt
Present simple vs present continuous pptPresent simple vs present continuous ppt
Present simple vs present continuous ppt
 
"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design Principles"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design Principles
 
Dry
DryDry
Dry
 
Test Driven Design - GDG DevFest Istanbul 2016
Test Driven Design - GDG DevFest Istanbul 2016Test Driven Design - GDG DevFest Istanbul 2016
Test Driven Design - GDG DevFest Istanbul 2016
 

Similar to SOLID Design Principles

SOLID design principles in Ruby
SOLID design principles in RubySOLID design principles in Ruby
SOLID design principles in Ruby
Anil Wadghule
 
Developing solid applications
Developing solid applicationsDeveloping solid applications
Developing solid applications
Nilesh Bangar
 
.NET Architecture for Enterprises
.NET Architecture for Enterprises.NET Architecture for Enterprises
.NET Architecture for Enterprises
Wade Wegner
 
2015.01.09 - Writing Modern Applications for Mobile and Web
2015.01.09 - Writing Modern Applications for Mobile and Web2015.01.09 - Writing Modern Applications for Mobile and Web
2015.01.09 - Writing Modern Applications for Mobile and Web
Marco Parenzan
 

Similar to SOLID Design Principles (20)

SOLID design principles in Ruby
SOLID design principles in RubySOLID design principles in Ruby
SOLID design principles in Ruby
 
Paris Web - Javascript as a programming language
Paris Web - Javascript as a programming languageParis Web - Javascript as a programming language
Paris Web - Javascript as a programming language
 
Do we need SOLID principles during software development?
Do we need SOLID principles during software development?Do we need SOLID principles during software development?
Do we need SOLID principles during software development?
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and Patterns
 
Better and Faster: A Journey Toward Clean Code and Enjoyment
Better and Faster: A Journey Toward Clean Code and EnjoymentBetter and Faster: A Journey Toward Clean Code and Enjoyment
Better and Faster: A Journey Toward Clean Code and Enjoyment
 
Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 from an HTML5 Perspective, JavaLand 2015Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 from an HTML5 Perspective, JavaLand 2015
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principles
 
Android architecture
Android architectureAndroid architecture
Android architecture
 
Refactoring to SOLID Code
Refactoring to SOLID CodeRefactoring to SOLID Code
Refactoring to SOLID Code
 
Framework Engineering 2.1
Framework Engineering 2.1Framework Engineering 2.1
Framework Engineering 2.1
 
SOLID Design principles
SOLID Design principlesSOLID Design principles
SOLID Design principles
 
Developing solid applications
Developing solid applicationsDeveloping solid applications
Developing solid applications
 
Enlightenment: A Cross Platform Window Manager & Toolkit
Enlightenment: A Cross Platform Window Manager & ToolkitEnlightenment: A Cross Platform Window Manager & Toolkit
Enlightenment: A Cross Platform Window Manager & Toolkit
 
CommonJS via PINF JavaScript Loader - Introduction
CommonJS via PINF JavaScript Loader - IntroductionCommonJS via PINF JavaScript Loader - Introduction
CommonJS via PINF JavaScript Loader - Introduction
 
.NET Architecture for Enterprises
.NET Architecture for Enterprises.NET Architecture for Enterprises
.NET Architecture for Enterprises
 
Is your code SOLID enough?
 Is your code SOLID enough? Is your code SOLID enough?
Is your code SOLID enough?
 
Solid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile developmentSolid OO & Clean Coding is essential to successful Agile development
Solid OO & Clean Coding is essential to successful Agile development
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test Automaion
 
Introducing Clean Architecture
Introducing Clean ArchitectureIntroducing Clean Architecture
Introducing Clean Architecture
 
2015.01.09 - Writing Modern Applications for Mobile and Web
2015.01.09 - Writing Modern Applications for Mobile and Web2015.01.09 - Writing Modern Applications for Mobile and Web
2015.01.09 - Writing Modern Applications for Mobile and Web
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

SOLID Design Principles

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n