SlideShare a Scribd company logo
1 of 28
Principles behind good software design

  IS YOUR CODE SOLID?
nathangloyn
@NathanGloyn
Design Code Release
nathan@gloyn.co.uk
Agenda

 The origin of S.O.L.I.D
 What is S.O.L.I.D?
 Design Smells
 The principles
 S.O.L.I.D code is...
 Summary
 Questions
 Resources
The origin of S.O.L.I.D
 Who is this man?
The origin of S.O.L.I.D
Principles, Patterns, and Practices
                           Published in 2002
                           First book to mention
                            SOLID
                           C# edition published 2005
                           Both books considered
                            seminal works on SOLID
What is S.O.L.I.D?

 Principles about class design
 To be considered, not rules blindly applied
 Made up of acronyms
 Minimise design smells
 Easier to evolve code
Design Smells

 Rigidity
 Fragility
 Immobility
 Viscosity
 Needless Complexity
 Needless Repetition
 Opacity
The principles

 S ingle Responsibility Principle   –>   SRP
   O pen/Closed Principle           –>   OCP
   L iskov Substitution Principle   –>   LSP
   I nterface Segregation Principle –>   ISP
   D ependency Inversion Principle –>    DIP
The principles
   Single Responsibility Principle

    What is the principle?
       A class should have only one reason to change.


    Why should you use it?
       Helps with separation of concerns
       Increases cohesion
       Reduces coupling
       Simplifies the code, making it more readable
       Makes future changes easier
The principles
   Single Responsibility Principle



     Code
The principles
   Interface Segregation Principle

    What is the principle?
       Clients should not be forced to depend upon
        interfaces that they do not use
       Avoid “fat” interfaces
    Why should you use it?
       Reduces coupling
       Implementers only use bits they need.
       Helps reduce dependencies
The principles
   Interface Segregation Principle


     Code
The principles
   Dependency Inversion Principle

    What is the principle?
       High-level modules should not depend on low-
        level modules. Both should depend on
        abstractions.
       Abstractions should not depend upon details.
        Details should depend upon abstractions.
       Don’t call us, we’ll call you
The principles
   Dependency Inversion Principle


     Policy Layer




                    Mechanism Layer




                                      Utility Layer
The principles
   Dependency Inversion Principle

                     Policy Service
     Policy Layer
                       Interface




                                      Mechanism Service
                    Mechanism Layer
                                          Interface




                                         Utility Layer
The principles
   Dependency Inversion Principle

                       Policy Service   Mechanism Service
     Policy Layer
                         Interface          Interface




                    Mechanism Layer




                                         Utility Layer
The principles
   Dependency Inversion Principle

    Why should you use it?
       Reduces coupling
       Makes it easier to reuse classes
       Can make code easier to test
       Use IoC to help implement
The principles
   Dependency Inversion Principle


     Code
The principles
   Open/closed Principle
    What is the principle?
       Software entities
        (classes, modules, functions, etc.) should be open
        for extension but closed for modification.
       Add new code, don’t touch the old code
    Why should you use it?
       Systems easier to change/evolve
       Reduces risk
       Develop and test extensions in isolation
The principles
   Open/closed Principle


     Code
The principles
   Liskov Substitution Principle
    What is the principle?
       If for each object o1 of type S there is an object o2
        of type T such that for all programs P defined in
        terms of T, the behavior of P is unchanged when
        o1 is substituted for o2 then S is a subtype of T.
       Subtypes must be substitutable for their base
        types.
The principles
   Liskov Substitution Principle
    Why should you use it?
       Consistent behaviour
       Reduces coupling
       Makes it easier to evolve code
The principles
   Liskov Substitution Principle

                            Fail
The principles
   Liskov Substitution Principle


     Code
The principles

 S ingle Responsibility Principle         –> SRP
   A class should have only one reason to change.
 O pen/Closed Principle                   –> OCP
   Add new code, don’t touch the old code
 L iskov Substitution Principle           –> LSP
   Subtypes must be substitutable for their base types
 I nterface Segregation Principle –>           ISP
  Avoid “fat” interfaces
 D ependency Inversion Principle –>            DIP
  Don’t call us, we’ll call you
S.O.L.I.D code is...

  Loosely coupled
  Highly cohesive
  Easy to evolve/change
  Testable
Summary

 Not new, been around a while
 Principles not rules
 You decide when to apply
 It should make it easier to evolve code
 Code will be easier to unit test
Questions?
Resources
 Principles Of Ood
 DimeCasts.Net – screen casts on each principle
 Los Techies – series of posts on principles
 Hanselminutes – podcast with Uncle Bob
 Getting a good SOLID start – post by Uncle bob
 Presentation Code – code from the presentation



 nathangloyn                    Design Code Release
 @NathanGloyn                   nathan@gloyn.co.uk

More Related Content

Similar to Is your code solid

SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionKnoldus Inc.
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsBasavaraj Patil
 
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 developmentSimon Gould
 
SOLID principles-Present
SOLID principles-PresentSOLID principles-Present
SOLID principles-PresentQuang Nguyen
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design PrinciplesSteve Zhang
 
Is your code SOLID enough?
 Is your code SOLID enough? Is your code SOLID enough?
Is your code SOLID enough?SARCCOM
 
Common Design Patterns.pptx
Common Design Patterns.pptxCommon Design Patterns.pptx
Common Design Patterns.pptxfake195786
 
Agile design pattern
Agile design patternAgile design pattern
Agile design patternPoppy Martono
 
Solid design principles
Solid design principlesSolid design principles
Solid design principlesMahmoud Asadi
 
Geecon09: SOLID Design Principles
Geecon09: SOLID Design PrinciplesGeecon09: SOLID Design Principles
Geecon09: SOLID Design PrinciplesBruno Bossola
 
Daniel leon design principles in the functional world
Daniel leon   design principles in the functional worldDaniel leon   design principles in the functional world
Daniel leon design principles in the functional worldCodecamp Romania
 
Software design principles
Software design principlesSoftware design principles
Software design principlesMd.Mojibul Hoque
 
SOLID design principles in Ruby
SOLID design principles in RubySOLID design principles in Ruby
SOLID design principles in RubyAnil Wadghule
 

Similar to Is your code solid (20)

SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test Automaion
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
 
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
SolidSolid
Solid
 
Android architecture
Android architectureAndroid architecture
Android architecture
 
SOLID principles-Present
SOLID principles-PresentSOLID principles-Present
SOLID principles-Present
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design Principles
 
Is your code SOLID enough?
 Is your code SOLID enough? Is your code SOLID enough?
Is your code SOLID enough?
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Common Design Patterns.pptx
Common Design Patterns.pptxCommon Design Patterns.pptx
Common Design Patterns.pptx
 
Agile design pattern
Agile design patternAgile design pattern
Agile design pattern
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Solid design principles
Solid design principlesSolid design principles
Solid design principles
 
Soild principles
Soild principlesSoild principles
Soild principles
 
Solid
SolidSolid
Solid
 
Geecon09: SOLID Design Principles
Geecon09: SOLID Design PrinciplesGeecon09: SOLID Design Principles
Geecon09: SOLID Design Principles
 
Daniel leon design principles in the functional world
Daniel leon   design principles in the functional worldDaniel leon   design principles in the functional world
Daniel leon design principles in the functional world
 
Software design principles
Software design principlesSoftware design principles
Software design principles
 
SOLID design principles in Ruby
SOLID design principles in RubySOLID design principles in Ruby
SOLID design principles in Ruby
 
Solid principes
Solid principesSolid principes
Solid principes
 

More from Nathan Gloyn

Microservices - What I've learned after a year building systems
Microservices - What I've learned after a year building systemsMicroservices - What I've learned after a year building systems
Microservices - What I've learned after a year building systemsNathan Gloyn
 
You keep using the word agile, i do not think it means what you think it means
You keep using the word agile, i do not think it means what you think it meansYou keep using the word agile, i do not think it means what you think it means
You keep using the word agile, i do not think it means what you think it meansNathan Gloyn
 
Selenium ui paradigm - DDD North 2
Selenium ui paradigm - DDD North 2Selenium ui paradigm - DDD North 2
Selenium ui paradigm - DDD North 2Nathan Gloyn
 
Inversion of control containers vs handrolled how they compare
Inversion of control containers vs handrolled   how they compareInversion of control containers vs handrolled   how they compare
Inversion of control containers vs handrolled how they compareNathan Gloyn
 
DDD North - Kanban what is it and how can it help
DDD North - Kanban what is it and how can it helpDDD North - Kanban what is it and how can it help
DDD North - Kanban what is it and how can it helpNathan Gloyn
 
You think you know agile
You think you know agileYou think you know agile
You think you know agileNathan Gloyn
 

More from Nathan Gloyn (7)

Microservices - What I've learned after a year building systems
Microservices - What I've learned after a year building systemsMicroservices - What I've learned after a year building systems
Microservices - What I've learned after a year building systems
 
You keep using the word agile, i do not think it means what you think it means
You keep using the word agile, i do not think it means what you think it meansYou keep using the word agile, i do not think it means what you think it means
You keep using the word agile, i do not think it means what you think it means
 
No backend
No backendNo backend
No backend
 
Selenium ui paradigm - DDD North 2
Selenium ui paradigm - DDD North 2Selenium ui paradigm - DDD North 2
Selenium ui paradigm - DDD North 2
 
Inversion of control containers vs handrolled how they compare
Inversion of control containers vs handrolled   how they compareInversion of control containers vs handrolled   how they compare
Inversion of control containers vs handrolled how they compare
 
DDD North - Kanban what is it and how can it help
DDD North - Kanban what is it and how can it helpDDD North - Kanban what is it and how can it help
DDD North - Kanban what is it and how can it help
 
You think you know agile
You think you know agileYou think you know agile
You think you know agile
 

Recently uploaded

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?Igalia
 
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...Martijn de Jong
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
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 educationjfdjdjcjdnsjd
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
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...Drew Madelung
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
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 RobisonAnna Loughnan Colquhoun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Recently uploaded (20)

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?
 
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...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Is your code solid

  • 1. Principles behind good software design IS YOUR CODE SOLID? nathangloyn @NathanGloyn Design Code Release nathan@gloyn.co.uk
  • 2. Agenda  The origin of S.O.L.I.D  What is S.O.L.I.D?  Design Smells  The principles  S.O.L.I.D code is...  Summary  Questions  Resources
  • 3. The origin of S.O.L.I.D Who is this man?
  • 4. The origin of S.O.L.I.D Principles, Patterns, and Practices  Published in 2002  First book to mention SOLID  C# edition published 2005  Both books considered seminal works on SOLID
  • 5. What is S.O.L.I.D?  Principles about class design  To be considered, not rules blindly applied  Made up of acronyms  Minimise design smells  Easier to evolve code
  • 6. Design Smells  Rigidity  Fragility  Immobility  Viscosity  Needless Complexity  Needless Repetition  Opacity
  • 7. The principles  S ingle Responsibility Principle –> SRP  O pen/Closed Principle –> OCP  L iskov Substitution Principle –> LSP  I nterface Segregation Principle –> ISP  D ependency Inversion Principle –> DIP
  • 8. The principles Single Responsibility Principle  What is the principle?  A class should have only one reason to change.  Why should you use it?  Helps with separation of concerns  Increases cohesion  Reduces coupling  Simplifies the code, making it more readable  Makes future changes easier
  • 9. The principles Single Responsibility Principle Code
  • 10. The principles Interface Segregation Principle  What is the principle?  Clients should not be forced to depend upon interfaces that they do not use  Avoid “fat” interfaces  Why should you use it?  Reduces coupling  Implementers only use bits they need.  Helps reduce dependencies
  • 11. The principles Interface Segregation Principle Code
  • 12. The principles Dependency Inversion Principle  What is the principle?  High-level modules should not depend on low- level modules. Both should depend on abstractions.  Abstractions should not depend upon details. Details should depend upon abstractions.  Don’t call us, we’ll call you
  • 13. The principles Dependency Inversion Principle Policy Layer Mechanism Layer Utility Layer
  • 14. The principles Dependency Inversion Principle Policy Service Policy Layer Interface Mechanism Service Mechanism Layer Interface Utility Layer
  • 15. The principles Dependency Inversion Principle Policy Service Mechanism Service Policy Layer Interface Interface Mechanism Layer Utility Layer
  • 16. The principles Dependency Inversion Principle  Why should you use it?  Reduces coupling  Makes it easier to reuse classes  Can make code easier to test  Use IoC to help implement
  • 17. The principles Dependency Inversion Principle Code
  • 18. The principles Open/closed Principle  What is the principle?  Software entities (classes, modules, functions, etc.) should be open for extension but closed for modification.  Add new code, don’t touch the old code  Why should you use it?  Systems easier to change/evolve  Reduces risk  Develop and test extensions in isolation
  • 19. The principles Open/closed Principle Code
  • 20. The principles Liskov Substitution Principle  What is the principle?  If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T.  Subtypes must be substitutable for their base types.
  • 21. The principles Liskov Substitution Principle  Why should you use it?  Consistent behaviour  Reduces coupling  Makes it easier to evolve code
  • 22. The principles Liskov Substitution Principle Fail
  • 23. The principles Liskov Substitution Principle Code
  • 24. The principles  S ingle Responsibility Principle –> SRP  A class should have only one reason to change.  O pen/Closed Principle –> OCP  Add new code, don’t touch the old code  L iskov Substitution Principle –> LSP  Subtypes must be substitutable for their base types  I nterface Segregation Principle –> ISP  Avoid “fat” interfaces  D ependency Inversion Principle –> DIP  Don’t call us, we’ll call you
  • 25. S.O.L.I.D code is...  Loosely coupled  Highly cohesive  Easy to evolve/change  Testable
  • 26. Summary  Not new, been around a while  Principles not rules  You decide when to apply  It should make it easier to evolve code  Code will be easier to unit test
  • 28. Resources  Principles Of Ood  DimeCasts.Net – screen casts on each principle  Los Techies – series of posts on principles  Hanselminutes – podcast with Uncle Bob  Getting a good SOLID start – post by Uncle bob  Presentation Code – code from the presentation nathangloyn Design Code Release @NathanGloyn nathan@gloyn.co.uk