SlideShare une entreprise Scribd logo
1  sur  22
SOLID -  OO DESIGN PRINCIPLES Andreas Enbohm, Capgemini
Agenda ,[object Object],[object Object],[object Object],26 augusti 2011 Sida
SOLID ,[object Object],[object Object],[object Object],26 augusti 2011 Sida
SOLID ,[object Object],[object Object],[object Object],26 augusti 2011 Sida
Single  Responsibility  Principle ,[object Object],[object Object],26 augusti 2011 Sida
Single Responsibility Principle ,[object Object],[object Object],26 augusti 2011 Sida  interface Modem { public void dial(String pno); public void hangup(); public void send(char c); public char recv(); }
Single Responsibility Principle ,[object Object],26 augusti 2011 Sida  interface DataChannel { public void send(char c); public char recv(); } interface Connection { public void dial(String phn); public char hangup(); }
Open Closed Principle ,[object Object],[object Object],26 augusti 2011 Sida
Open Closed Principle 26 augusti 2011 Sida  // Open-Close Principle - Bad example class GraphicEditor { public void drawShape(Shape s) { if (s.m_type==1) drawRectangle(s); else if (s.m_type==2) drawCircle(s); } public void drawCircle(Circle r) {....} public void drawRectangle(Rectangle r) {....} } class Shape { int m_type; } class Rectangle extends Shape { Rectangle() { super.m_type=1; } } class Circle extends Shape { Circle() { super.m_type=2; } }
Open Closed Principle – a Few Problems…. ,[object Object],[object Object],[object Object],[object Object],[object Object],26 augusti 2011 Sida
Open Closed Principle - Improved ,[object Object],26 augusti 2011 Sida
Liskov Substitution Principle ,[object Object],[object Object],26 augusti 2011 Sida
Liskov Substitution Principle 26 augusti 2011 Sida  // Violation of Liskov's  Substitution   Principle class Rectangle { int m_width; int m_height; public void setWidth(int width){ m_width = width; } public void setHeight(int h){ m_height = ht; } public int getWidth(){ return m_width; } public int getHeight(){ return m_height; } public int getArea(){ return m_width * m_height; }  } class Square extends Rectangle  { public void setWidth(int width){ m_width = width; m_height = width; } public void setHeight(int height){ m_width = height; m_height = height; } }
Liskov Substitution Principle ,[object Object],[object Object],26 augusti 2011 Sida
Interface Segregation Principle ,[object Object],[object Object],26 augusti 2011 Sida
Interface Segregation Principle ,[object Object],[object Object],[object Object],26 augusti 2011 Sida
Interface Segregation Principle 26 augusti 2011 Sida  //bad example (polluted interface) interface Worker { void work(); void eat(); } ManWorker implements Worker { void work() {…}; void eat() {30 min break;}; } RobotWorker implements Worker { void work() {…}; void eat() {//Not Appliciable  for a RobotWorker}; }
Interface Segregation Principle ,[object Object],26 augusti 2011 Sida  interface Workable { public void work(); } interface Feedable{ public void eat(); }
Dependency Inversion Principle ,[object Object],[object Object],26 augusti 2011 Sida
Dependency Inversion Principle 26 augusti 2011 Sida  //DIP - bad example public class EmployeeService { private EmployeeFinder emFinder //concrete class, not abstract. Can access a SQL DB for instance public Employee findEmployee(…) { emFinder.findEmployee(…) } }
Dependency Inversion Principle ,[object Object],26 augusti 2011 Sida  //DIP - fixed public class EmployeeService { private IEmployeeFinder emFinder //depends on an abstraction, no an implementation public Employee findEmployee(…) { emFinder.findEmployee(…) } }
Q&A ,[object Object],[object Object],[object Object],[object Object],26 augusti 2011 Sida

Contenu connexe

Tendances

Tendances (20)

Introduction to SOLID Principles
Introduction to SOLID PrinciplesIntroduction to SOLID Principles
Introduction to SOLID Principles
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLID
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
SOLID
SOLIDSOLID
SOLID
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
Solid design principles
Solid design principlesSolid design principles
Solid design principles
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
Clean code
Clean codeClean code
Clean code
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Introducing Clean Architecture
Introducing Clean ArchitectureIntroducing Clean Architecture
Introducing Clean Architecture
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
Clean code: SOLID (iOS)
Clean code: SOLID (iOS)Clean code: SOLID (iOS)
Clean code: SOLID (iOS)
 

Similaire à SOLID Design Principles

Object Oriented Principle’s
Object Oriented Principle’sObject Oriented Principle’s
Object Oriented Principle’svivek p s
 
An Introduction to the SOLID Principles
An Introduction to the SOLID PrinciplesAn Introduction to the SOLID Principles
An Introduction to the SOLID PrinciplesAttila Bertók
 
Solid Principles
Solid PrinciplesSolid Principles
Solid PrinciplesHitheshh
 
The maze of Design Patterns & SOLID Principles
The maze of Design Patterns & SOLID PrinciplesThe maze of Design Patterns & SOLID Principles
The maze of Design Patterns & SOLID PrinciplesMuhammad Raza
 
The good, the bad and the SOLID
The good, the bad and the SOLIDThe good, the bad and the SOLID
The good, the bad and the SOLIDFrikkie van Biljon
 
Object Design - Part 1
Object Design - Part 1Object Design - Part 1
Object Design - Part 1Dhaval Dalal
 
Design Patterns
Design PatternsDesign Patterns
Design Patternsadil raja
 
Introduction to Object oriented Design
Introduction to Object oriented DesignIntroduction to Object oriented Design
Introduction to Object oriented DesignAmin Shahnazari
 
Solid principles
Solid principlesSolid principles
Solid principlesViet Vu
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3Naga Muruga
 
Design Patterns - Part 1 of 2
Design Patterns - Part 1 of 2Design Patterns - Part 1 of 2
Design Patterns - Part 1 of 2Savio Sebastian
 
Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"LogeekNightUkraine
 
Design principle vs design patterns
Design principle vs design patternsDesign principle vs design patterns
Design principle vs design patternsPrabhakar Sharma
 
Programming for a better world
Programming for a better worldProgramming for a better world
Programming for a better worldjhansi reddy
 
Software Frameworks
Software FrameworksSoftware Frameworks
Software Frameworksadil raja
 

Similaire à SOLID Design Principles (20)

Object Oriented Principle’s
Object Oriented Principle’sObject Oriented Principle’s
Object Oriented Principle’s
 
An Introduction to the SOLID Principles
An Introduction to the SOLID PrinciplesAn Introduction to the SOLID Principles
An Introduction to the SOLID Principles
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
L22 Design Principles
L22 Design PrinciplesL22 Design Principles
L22 Design Principles
 
Oop principles
Oop principlesOop principles
Oop principles
 
Solid js
Solid jsSolid js
Solid js
 
The maze of Design Patterns & SOLID Principles
The maze of Design Patterns & SOLID PrinciplesThe maze of Design Patterns & SOLID Principles
The maze of Design Patterns & SOLID Principles
 
The good, the bad and the SOLID
The good, the bad and the SOLIDThe good, the bad and the SOLID
The good, the bad and the SOLID
 
Object Design - Part 1
Object Design - Part 1Object Design - Part 1
Object Design - Part 1
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Introduction to Object oriented Design
Introduction to Object oriented DesignIntroduction to Object oriented Design
Introduction to Object oriented Design
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3
 
Design Patterns - Part 1 of 2
Design Patterns - Part 1 of 2Design Patterns - Part 1 of 2
Design Patterns - Part 1 of 2
 
Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"
 
L07 Design Principles
L07 Design PrinciplesL07 Design Principles
L07 Design Principles
 
Solid principle
Solid principleSolid principle
Solid principle
 
Design principle vs design patterns
Design principle vs design patternsDesign principle vs design patterns
Design principle vs design patterns
 
Programming for a better world
Programming for a better worldProgramming for a better world
Programming for a better world
 
Software Frameworks
Software FrameworksSoftware Frameworks
Software Frameworks
 

Plus de Andreas Enbohm

Plus de Andreas Enbohm (9)

BDD Short Introduction
BDD Short IntroductionBDD Short Introduction
BDD Short Introduction
 
Behavior-driven Development and Lambdaj
Behavior-driven Development and LambdajBehavior-driven Development and Lambdaj
Behavior-driven Development and Lambdaj
 
Hybrid Applications
Hybrid ApplicationsHybrid Applications
Hybrid Applications
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software Craftsmanship
 
Java7 - Top 10 Features
Java7 - Top 10 FeaturesJava7 - Top 10 Features
Java7 - Top 10 Features
 
Java Extension Methods
Java Extension MethodsJava Extension Methods
Java Extension Methods
 
Scala
ScalaScala
Scala
 
Project Lambda - Closures after all?
Project Lambda - Closures after all?Project Lambda - Closures after all?
Project Lambda - Closures after all?
 
Fest
FestFest
Fest
 

Dernier

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 

Dernier (20)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 

SOLID Design Principles

  • 1. SOLID - OO DESIGN PRINCIPLES Andreas Enbohm, Capgemini
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. Open Closed Principle 26 augusti 2011 Sida // Open-Close Principle - Bad example class GraphicEditor { public void drawShape(Shape s) { if (s.m_type==1) drawRectangle(s); else if (s.m_type==2) drawCircle(s); } public void drawCircle(Circle r) {....} public void drawRectangle(Rectangle r) {....} } class Shape { int m_type; } class Rectangle extends Shape { Rectangle() { super.m_type=1; } } class Circle extends Shape { Circle() { super.m_type=2; } }
  • 10.
  • 11.
  • 12.
  • 13. Liskov Substitution Principle 26 augusti 2011 Sida // Violation of Liskov's Substitution Principle class Rectangle { int m_width; int m_height; public void setWidth(int width){ m_width = width; } public void setHeight(int h){ m_height = ht; } public int getWidth(){ return m_width; } public int getHeight(){ return m_height; } public int getArea(){ return m_width * m_height; } } class Square extends Rectangle { public void setWidth(int width){ m_width = width; m_height = width; } public void setHeight(int height){ m_width = height; m_height = height; } }
  • 14.
  • 15.
  • 16.
  • 17. Interface Segregation Principle 26 augusti 2011 Sida //bad example (polluted interface) interface Worker { void work(); void eat(); } ManWorker implements Worker { void work() {…}; void eat() {30 min break;}; } RobotWorker implements Worker { void work() {…}; void eat() {//Not Appliciable for a RobotWorker}; }
  • 18.
  • 19.
  • 20. Dependency Inversion Principle 26 augusti 2011 Sida //DIP - bad example public class EmployeeService { private EmployeeFinder emFinder //concrete class, not abstract. Can access a SQL DB for instance public Employee findEmployee(…) { emFinder.findEmployee(…) } }
  • 21.
  • 22.