SlideShare a Scribd company logo
1 of 24
Download to read offline
SOLID Principles
Clean Code: The Solid Principles
Robert C. Martin (Uncle Bob)
 Software Craftsman
 http://www.cleancoder.com
 twitter: @unclebobmartin
 OOP seit den 70ern
 Unterzeichner "Agiles Manifest"
 Books
 Clean Code. A Handbook of Agile Software
Craftsmanship
 The Clean Coder. A Code of Conduct for Professional
Programmers
5 Solid Principles
 Der Source Code ist das Design, nicht das Produkt
 Die Software ist das Produkt
Single Responsibility Principle
Single Responsibility Principle
Single Responsibility
Principle
„There should never be more than one reason for a class to
change.“
„Es sollte nie mehr als einen Grund dafür geben, eine
Klasse zu ändern.“
 Robert C. Martin (Uncle Bob): Agile Software
Development: Principles, Patterns, and Practices
Open Close Principle
Open Close Principle
Open Close Principle
„Modules should be both open (for extension) and
closed (for modification).“
„Module sollten sowohl offen (für Erweiterungen), als
auch geschlossen (für Modifikationen) sein.“
 Bertrand Meyer: Object Oriented Software
Construction
Liskovsches
Substitutionsprinzip (LSP)
Liskovsches
Substitutionsprinzip (LSP)
Liskovsches
Substitutionsprinzip (LSP)
„Let q(x) be a property provable about objects x of
type T. Then q(y) should be true for objects y of
type S where S is a subtype of T“
„Sei q(x) eine Eigenschaft des Objektes x vom
Typ T, dann sollte q(y) für alle Objekte y des Typs
S gelten, wo S ein Subtyp von T ist.“
 Eine Childklasse soll sich so verhalten wie es von
der Elternklasse erwartet wird, daher ist eine
Objekt Ersetzbarkeit gegeben.
 1993 Barbara Liskov und Jeannette Wing
Interface Segregation
Principle
Interface Segregation
Principle
Interface Segregation
Principle – walk() and stand() seperated
Interface Segregation
Principle
„Clients should not be forced to depend upon
interfaces that they do not use.“
„Clients sollten nicht dazu gezwungen werden,
von Interfaces abzuhängen, die sie nicht
verwenden.“
 Robert C. Martin: The Interface Segregation
Principle
 http://www.objectmentor.com/resources/ar
ticles/isp.pdf
Dependency Inversion
Principle
Dependency Inversion
Principle
„A. High-level modules should not depend on low level modules.
Both should depend on abstractions.
B. Abstractions should not depend upon details. Details should
depend upon abstractions.“
A. Module hoher Ebenen sollten nicht von Modulen niedriger
Ebenen abhängen. Beide sollten von Abstraktionen abhängen.
B. Abstraktionen sollten nicht von Details abhängen. Details
sollten von Abstraktionen abhängen.“
 Robert C. Martin: The Dependency Inversion Principle. 5/1996
SOLID
 Single responsibility principle (SRP)
 Open closed principle (OCP)
 Liskov substitution principle (LSP)
 Interface segregation principleI (ISP)
 Dependency inversion principle (DIP)
SOLID
 Single responsibility principle (SRP)
 Open closed principle (OCP)
 Liskov substitution principle (LSP)
 Interface segregation principleI (ISP)
 Dependency inversion principle (DIP)
SOLID in der Praxis
 Wie wende ich SOLID Prinzipien in der Praxis an ?
 Welche Hürden und Fallstricke gibt es ?
 Was wird oft gegen solche Prinzipien angeführt ?
 Wer entscheidet was eine Responsibility ist ?
Lose Kopplung und hohe
Kohäsion
 Loose Coupling
 Nicht zu feste Verknüpfung
 High Cohesion
 Hohe Spezialisierung
 Jede Klasse für genau eine wohldefinierte Aufgabe zuständig
Wie Solid seid ihr?
 Erfahrungsberichte der Entwickler
 Solid review im Code
Weblinks
 Artikel im OOP Buch
 http://openbook.galileocomputing.de/oop/oop_kapitel
_03_007.htm
 Wikipedia Artikel
 http://de.wikipedia.org/wiki/Prinzipien_Objektorientie
rten_Designs
 Java Beispiele
 http://java-ccd.blogspot.de/2010/08/rock-solid.html
 http://clean-code-developer.de/
 http://www.cleancoders.com/

More Related Content

Viewers also liked

Wb engineering
Wb engineeringWb engineering
Wb engineeringJason899
 
Unified Security Plugin for Opendaylight Controller
Unified Security Plugin for Opendaylight ControllerUnified Security Plugin for Opendaylight Controller
Unified Security Plugin for Opendaylight ControllerSaikat Chaudhuri
 
Gaurav Kumar Resume
Gaurav Kumar ResumeGaurav Kumar Resume
Gaurav Kumar ResumeGaurav kumar
 
IT Next January 2010 Issue
IT Next January 2010 IssueIT Next January 2010 Issue
IT Next January 2010 IssueShashwat DC
 
The munoz migration - geography family tree1
The munoz migration - geography family tree1The munoz migration - geography family tree1
The munoz migration - geography family tree1pmunoz01
 
The Creditsafe Commercial Credit Managment Suite
The Creditsafe Commercial Credit Managment Suite The Creditsafe Commercial Credit Managment Suite
The Creditsafe Commercial Credit Managment Suite CreditsafeUK
 
Radisys Optimizing VAS for Greater Revenue Generation
Radisys Optimizing VAS for Greater Revenue GenerationRadisys Optimizing VAS for Greater Revenue Generation
Radisys Optimizing VAS for Greater Revenue GenerationRadisys Corporation
 
IBM X Force threat intelligence quarterly 1Q 2014
IBM X Force threat intelligence quarterly 1Q 2014IBM X Force threat intelligence quarterly 1Q 2014
IBM X Force threat intelligence quarterly 1Q 2014IBM Software India
 
Training & Development at Jindal SAW Ltd
Training & Development at Jindal SAW LtdTraining & Development at Jindal SAW Ltd
Training & Development at Jindal SAW LtdPrateek Gahlot
 

Viewers also liked (13)

Wb engineering
Wb engineeringWb engineering
Wb engineering
 
Unified Security Plugin for Opendaylight Controller
Unified Security Plugin for Opendaylight ControllerUnified Security Plugin for Opendaylight Controller
Unified Security Plugin for Opendaylight Controller
 
Gaurav Kumar Resume
Gaurav Kumar ResumeGaurav Kumar Resume
Gaurav Kumar Resume
 
NREF Annual Report
NREF Annual ReportNREF Annual Report
NREF Annual Report
 
Rrgreenhandslof
RrgreenhandslofRrgreenhandslof
Rrgreenhandslof
 
IT Next January 2010 Issue
IT Next January 2010 IssueIT Next January 2010 Issue
IT Next January 2010 Issue
 
The munoz migration - geography family tree1
The munoz migration - geography family tree1The munoz migration - geography family tree1
The munoz migration - geography family tree1
 
GetBetter
GetBetterGetBetter
GetBetter
 
The Creditsafe Commercial Credit Managment Suite
The Creditsafe Commercial Credit Managment Suite The Creditsafe Commercial Credit Managment Suite
The Creditsafe Commercial Credit Managment Suite
 
Radisys Optimizing VAS for Greater Revenue Generation
Radisys Optimizing VAS for Greater Revenue GenerationRadisys Optimizing VAS for Greater Revenue Generation
Radisys Optimizing VAS for Greater Revenue Generation
 
ICMA Quarterly Report - FIRST QUARTER 2014
ICMA Quarterly Report - FIRST QUARTER 2014ICMA Quarterly Report - FIRST QUARTER 2014
ICMA Quarterly Report - FIRST QUARTER 2014
 
IBM X Force threat intelligence quarterly 1Q 2014
IBM X Force threat intelligence quarterly 1Q 2014IBM X Force threat intelligence quarterly 1Q 2014
IBM X Force threat intelligence quarterly 1Q 2014
 
Training & Development at Jindal SAW Ltd
Training & Development at Jindal SAW LtdTraining & Development at Jindal SAW Ltd
Training & Development at Jindal SAW Ltd
 

OOP Principles

  • 1. SOLID Principles Clean Code: The Solid Principles
  • 2. Robert C. Martin (Uncle Bob)  Software Craftsman  http://www.cleancoder.com  twitter: @unclebobmartin  OOP seit den 70ern  Unterzeichner "Agiles Manifest"  Books  Clean Code. A Handbook of Agile Software Craftsmanship  The Clean Coder. A Code of Conduct for Professional Programmers
  • 3. 5 Solid Principles  Der Source Code ist das Design, nicht das Produkt  Die Software ist das Produkt
  • 6. Single Responsibility Principle „There should never be more than one reason for a class to change.“ „Es sollte nie mehr als einen Grund dafür geben, eine Klasse zu ändern.“  Robert C. Martin (Uncle Bob): Agile Software Development: Principles, Patterns, and Practices
  • 9. Open Close Principle „Modules should be both open (for extension) and closed (for modification).“ „Module sollten sowohl offen (für Erweiterungen), als auch geschlossen (für Modifikationen) sein.“  Bertrand Meyer: Object Oriented Software Construction
  • 12. Liskovsches Substitutionsprinzip (LSP) „Let q(x) be a property provable about objects x of type T. Then q(y) should be true for objects y of type S where S is a subtype of T“ „Sei q(x) eine Eigenschaft des Objektes x vom Typ T, dann sollte q(y) für alle Objekte y des Typs S gelten, wo S ein Subtyp von T ist.“  Eine Childklasse soll sich so verhalten wie es von der Elternklasse erwartet wird, daher ist eine Objekt Ersetzbarkeit gegeben.  1993 Barbara Liskov und Jeannette Wing
  • 15. Interface Segregation Principle – walk() and stand() seperated
  • 16. Interface Segregation Principle „Clients should not be forced to depend upon interfaces that they do not use.“ „Clients sollten nicht dazu gezwungen werden, von Interfaces abzuhängen, die sie nicht verwenden.“  Robert C. Martin: The Interface Segregation Principle  http://www.objectmentor.com/resources/ar ticles/isp.pdf
  • 18. Dependency Inversion Principle „A. High-level modules should not depend on low level modules. Both should depend on abstractions. B. Abstractions should not depend upon details. Details should depend upon abstractions.“ A. Module hoher Ebenen sollten nicht von Modulen niedriger Ebenen abhängen. Beide sollten von Abstraktionen abhängen. B. Abstraktionen sollten nicht von Details abhängen. Details sollten von Abstraktionen abhängen.“  Robert C. Martin: The Dependency Inversion Principle. 5/1996
  • 19. SOLID  Single responsibility principle (SRP)  Open closed principle (OCP)  Liskov substitution principle (LSP)  Interface segregation principleI (ISP)  Dependency inversion principle (DIP)
  • 20. SOLID  Single responsibility principle (SRP)  Open closed principle (OCP)  Liskov substitution principle (LSP)  Interface segregation principleI (ISP)  Dependency inversion principle (DIP)
  • 21. SOLID in der Praxis  Wie wende ich SOLID Prinzipien in der Praxis an ?  Welche Hürden und Fallstricke gibt es ?  Was wird oft gegen solche Prinzipien angeführt ?  Wer entscheidet was eine Responsibility ist ?
  • 22. Lose Kopplung und hohe Kohäsion  Loose Coupling  Nicht zu feste Verknüpfung  High Cohesion  Hohe Spezialisierung  Jede Klasse für genau eine wohldefinierte Aufgabe zuständig
  • 23. Wie Solid seid ihr?  Erfahrungsberichte der Entwickler  Solid review im Code
  • 24. Weblinks  Artikel im OOP Buch  http://openbook.galileocomputing.de/oop/oop_kapitel _03_007.htm  Wikipedia Artikel  http://de.wikipedia.org/wiki/Prinzipien_Objektorientie rten_Designs  Java Beispiele  http://java-ccd.blogspot.de/2010/08/rock-solid.html  http://clean-code-developer.de/  http://www.cleancoders.com/