SlideShare ist ein Scribd-Unternehmen logo
1 von 15
SOLID
The Open/Closed Principle
Dependency Inversion
Paul Blundell
@Blundell_apps
www.blundellapps.com
Five basic principles of object-orientated programming.
“The principles when applied together intend to make it more likely that a
programmer will create a system that is easy to maintain and extend
over time”
S ?
O ?
L ?
I ?
D ?
SOLID
Five basic principles of object-orientated programming.
“The principles when applied together intend to make it more likely that a
programmer will create a system that is easy to maintain and extend
over time”
Single Responsibility Principle
Open / Closed Principle
Liskov’s Substitution
Interface Segregation
Dependency Inversion
SOLID
Five basic principles of object-orientated programming.
“The principles when applied together intend to make it more likely that a
programmer will create a system that is easy to maintain and extend
over time”
Single Responsibility Principle
Open / Closed Principle
Liskov’s Substitution
Interface Segregation
Dependency Inversion
SOLID
Open / Closed Principle
?
SOLID
Open / Closed Principle
“Software entities (classes, modules,
methods etc) should be open for extension
but closed for modification”
That is such an entity can allow its behaviour
to be changed without altering its source
code.
SOLID
Open Closed Principle
Open Closed Principle
Dependency Inversion
The aim of the OCP kata is to use the Open
Closed Principle to design a maintainable
and extensible code base.
Think about:
- How to compose functionality out of existing
objects
- How to avoid reworking existing code
OCP Kata
Write the first failing test
Then write a factory that returns an object or
a composed object that makes the test
pass.
Rules:
- the factory should be limited to creating and
linking objects
- no conditionals allowed in the factory
OCP Kata
@Test
public void scoreZeroForGutterGame() {
// First test
}
@Test
public void scoreTwentyForAllOnesGame() {
// Second test
}
// Continue
Bowling OCP Kata
Write the next failing test
Can you make this test pass by just changing
the factory and object composite?
Yes - Great do it!
No - Refactor until you can
The refactoring should be the system to a state where it’s possible to
implement the next test just by changing the composite of objects that
is returned by the factory. Do not implement new functionality when
refactoring the current test must still fail.
OCP Kata
Fork / Clone this repo:
git@github.com:novoda/dojos.git
Goto this folder:
github.com/novoda/dojos/tree/master/ocpBowling
Make a copy of this folder (rename default with a team name):
github.com/novoda/dojos/tree/master/ocpBowling/20130918-default
Rules are in the repo here:
ocpBowling/20130918-default/src/main/java/com/bowling/bowling_rules.txt
Start!
OCP Kata
Matteo Vaccari
- invented the OCP Kata
- http://matteo.vaccari.name/blog/archives/293
David Nicolette
- created the OCP jigsaw diagram
Uncle Bob
- Creator of the original bowling Kata
- http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata
Kevin Rutherford
- guided me in the art of Kata’s
- http://silkandspinach.net/
Jonas Gauffin
- for the meme
- http://blog.gauffin.org/2012/05/solid-principles-with-real-world-examples/#.UjWDy9K_s2k
Credits
Paul Blundell
@Blundell_apps
www.blundellapps.com

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Open Close Principle
Open Close PrincipleOpen Close Principle
Open Close Principle
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLID
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#
 
Clean code: SOLID
Clean code: SOLIDClean code: SOLID
Clean code: SOLID
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
The Single Responsibility Principle
The Single Responsibility PrincipleThe Single Responsibility Principle
The Single Responsibility Principle
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
SOLID Design Principles applied in Java
SOLID Design Principles applied in JavaSOLID Design Principles applied in Java
SOLID Design Principles applied in Java
 
Introdução APIs RESTful
Introdução APIs RESTfulIntrodução APIs RESTful
Introdução APIs RESTful
 
Refactoring
RefactoringRefactoring
Refactoring
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
POO - 11 - Prática de Herança
POO - 11 - Prática de HerançaPOO - 11 - Prática de Herança
POO - 11 - Prática de Herança
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
Introduction Node.js
Introduction Node.jsIntroduction Node.js
Introduction Node.js
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 

Andere mochten auch

Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principlesrainynovember12
 
"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design Principles"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design PrinciplesSerhiy Oplakanets
 
SOLID - Principles of Object Oriented Design
SOLID - Principles of Object Oriented DesignSOLID - Principles of Object Oriented Design
SOLID - Principles of Object Oriented DesignRiccardo Cardin
 
The Open Closed Principle - Part 1 - The Original Version
The Open Closed Principle - Part 1 - The Original VersionThe Open Closed Principle - Part 1 - The Original Version
The Open Closed Principle - Part 1 - The Original VersionPhilip Schwarz
 
The Open-Closed Principle - the Original Version and the Contemporary Version
The Open-Closed Principle - the Original Version and the Contemporary VersionThe Open-Closed Principle - the Original Version and the Contemporary Version
The Open-Closed Principle - the Original Version and the Contemporary VersionPhilip Schwarz
 
SOLID refactoring - racing car katas
SOLID refactoring - racing car katasSOLID refactoring - racing car katas
SOLID refactoring - racing car katasGeorg Berky
 
Smolen Alex Securing The Mvc Architecture Part Two
Smolen Alex Securing The Mvc Architecture Part TwoSmolen Alex Securing The Mvc Architecture Part Two
Smolen Alex Securing The Mvc Architecture Part Twoalsmola
 
Solid principles
Solid principlesSolid principles
Solid principlesViet Vu
 
Implementing The Open/Closed Principle
Implementing The Open/Closed PrincipleImplementing The Open/Closed Principle
Implementing The Open/Closed PrincipleSam Hennessy
 
Panduan microsoft word_20071
Panduan microsoft word_20071Panduan microsoft word_20071
Panduan microsoft word_20071Amri Abdillah
 
Entrepreneurship from a regional market perspective
Entrepreneurship from a regional market perspectiveEntrepreneurship from a regional market perspective
Entrepreneurship from a regional market perspectiveRajaranjan Senapati
 
Roditelskoe sobranie 11klassy
Roditelskoe sobranie 11klassyRoditelskoe sobranie 11klassy
Roditelskoe sobranie 11klassylili4ka54
 
Justice ,justice shall you pursue
Justice ,justice shall you pursueJustice ,justice shall you pursue
Justice ,justice shall you pursueYonatanKay1
 
Rumus kima & persamaan kimia
Rumus kima & persamaan kimiaRumus kima & persamaan kimia
Rumus kima & persamaan kimiawidhiyani
 
Rumus kima & persamaan kimia
Rumus kima & persamaan kimiaRumus kima & persamaan kimia
Rumus kima & persamaan kimiawidhiyani
 

Andere mochten auch (20)

Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principles
 
SOLID Principles part 1
SOLID Principles part 1SOLID Principles part 1
SOLID Principles part 1
 
"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design Principles"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design Principles
 
SOLID - Principles of Object Oriented Design
SOLID - Principles of Object Oriented DesignSOLID - Principles of Object Oriented Design
SOLID - Principles of Object Oriented Design
 
The Open Closed Principle - Part 1 - The Original Version
The Open Closed Principle - Part 1 - The Original VersionThe Open Closed Principle - Part 1 - The Original Version
The Open Closed Principle - Part 1 - The Original Version
 
The Open-Closed Principle - the Original Version and the Contemporary Version
The Open-Closed Principle - the Original Version and the Contemporary VersionThe Open-Closed Principle - the Original Version and the Contemporary Version
The Open-Closed Principle - the Original Version and the Contemporary Version
 
OCP kata overview
OCP kata overviewOCP kata overview
OCP kata overview
 
Kata rules
Kata rulesKata rules
Kata rules
 
SOLID refactoring - racing car katas
SOLID refactoring - racing car katasSOLID refactoring - racing car katas
SOLID refactoring - racing car katas
 
Smolen Alex Securing The Mvc Architecture Part Two
Smolen Alex Securing The Mvc Architecture Part TwoSmolen Alex Securing The Mvc Architecture Part Two
Smolen Alex Securing The Mvc Architecture Part Two
 
Solid principles
Solid principlesSolid principles
Solid principles
 
jeas_0816_4883
jeas_0816_4883jeas_0816_4883
jeas_0816_4883
 
Implementing The Open/Closed Principle
Implementing The Open/Closed PrincipleImplementing The Open/Closed Principle
Implementing The Open/Closed Principle
 
Panduan microsoft word_20071
Panduan microsoft word_20071Panduan microsoft word_20071
Panduan microsoft word_20071
 
Entrepreneurship from a regional market perspective
Entrepreneurship from a regional market perspectiveEntrepreneurship from a regional market perspective
Entrepreneurship from a regional market perspective
 
Roditelskoe sobranie 11klassy
Roditelskoe sobranie 11klassyRoditelskoe sobranie 11klassy
Roditelskoe sobranie 11klassy
 
Open house2
Open house2Open house2
Open house2
 
Justice ,justice shall you pursue
Justice ,justice shall you pursueJustice ,justice shall you pursue
Justice ,justice shall you pursue
 
Rumus kima & persamaan kimia
Rumus kima & persamaan kimiaRumus kima & persamaan kimia
Rumus kima & persamaan kimia
 
Rumus kima & persamaan kimia
Rumus kima & persamaan kimiaRumus kima & persamaan kimia
Rumus kima & persamaan kimia
 

Ähnlich wie Open Closed Principle SOLID Principles Explained

Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternNishith Shukla
 
Jump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsJump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsLalit Kale
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principlesdeonpmeyer
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@Alex Borsuk
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsBasavaraj Patil
 
WebObjects Developer Tools
WebObjects Developer ToolsWebObjects Developer Tools
WebObjects Developer ToolsWO Community
 
Ansible top 10 - 2018
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018Viresh Doshi
 
Common design principles and design patterns in automation testing
Common design principles and design patterns in automation testingCommon design principles and design patterns in automation testing
Common design principles and design patterns in automation testingKMS Technology
 
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and EclipseGet ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and EclipseJeanne Boyarsky
 
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plansOpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plansMichael Vorburger
 
The software design principles
The software design principlesThe software design principles
The software design principlesAman Kesarwani
 

Ähnlich wie Open Closed Principle SOLID Principles Explained (20)

Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design Pattern
 
Jump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsJump Start To Ooad And Design Patterns
Jump Start To Ooad And Design Patterns
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@
 
Spring fundamentals
Spring fundamentalsSpring fundamentals
Spring fundamentals
 
Solid principle
Solid principleSolid principle
Solid principle
 
Java 9 Features
Java 9 FeaturesJava 9 Features
Java 9 Features
 
11th Salesforce Developer Group meeting in Bilbao
11th Salesforce Developer Group meeting in Bilbao11th Salesforce Developer Group meeting in Bilbao
11th Salesforce Developer Group meeting in Bilbao
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
 
Design for Testability
Design for TestabilityDesign for Testability
Design for Testability
 
Soild principles
Soild principlesSoild principles
Soild principles
 
Come si applica l'OCP
Come si applica l'OCPCome si applica l'OCP
Come si applica l'OCP
 
L2624 labriola
L2624 labriolaL2624 labriola
L2624 labriola
 
WebObjects Developer Tools
WebObjects Developer ToolsWebObjects Developer Tools
WebObjects Developer Tools
 
Ansible top 10 - 2018
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018
 
Common design principles and design patterns in automation testing
Common design principles and design patterns in automation testingCommon design principles and design patterns in automation testing
Common design principles and design patterns in automation testing
 
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and EclipseGet ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
 
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plansOpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
 
The software design principles
The software design principlesThe software design principles
The software design principles
 
Solid
SolidSolid
Solid
 

Mehr von Paul Blundell

In 10 mins a software crafting journey
In 10 mins a software crafting journeyIn 10 mins a software crafting journey
In 10 mins a software crafting journeyPaul Blundell
 
The Novoda Craft University
The Novoda Craft UniversityThe Novoda Craft University
The Novoda Craft UniversityPaul Blundell
 
Android Things - Solid Foundations
Android Things - Solid FoundationsAndroid Things - Solid Foundations
Android Things - Solid FoundationsPaul Blundell
 
Http Caching for the Android Aficionado
Http Caching for the Android AficionadoHttp Caching for the Android Aficionado
Http Caching for the Android AficionadoPaul Blundell
 
My perspective on MVP and architecture discussions
My perspective on MVP and architecture discussionsMy perspective on MVP and architecture discussions
My perspective on MVP and architecture discussionsPaul Blundell
 
Java Patterns - Strategy
Java Patterns - StrategyJava Patterns - Strategy
Java Patterns - StrategyPaul Blundell
 
Survival of the Continuist
Survival of the ContinuistSurvival of the Continuist
Survival of the ContinuistPaul Blundell
 
Google I/O 2015 Android & Tech Announcements
Google I/O 2015 Android & Tech AnnouncementsGoogle I/O 2015 Android & Tech Announcements
Google I/O 2015 Android & Tech AnnouncementsPaul Blundell
 
Android Jam - Services & Notifications - Udacity Lesson 6
Android Jam - Services & Notifications - Udacity Lesson 6 Android Jam - Services & Notifications - Udacity Lesson 6
Android Jam - Services & Notifications - Udacity Lesson 6 Paul Blundell
 
Android Jam - Loaders - Udacity Lesson 4c
Android Jam - Loaders - Udacity Lesson 4cAndroid Jam - Loaders - Udacity Lesson 4c
Android Jam - Loaders - Udacity Lesson 4cPaul Blundell
 
Android Jam - ContentProviders - Udacity Lesson 4b
Android Jam - ContentProviders - Udacity Lesson 4bAndroid Jam - ContentProviders - Udacity Lesson 4b
Android Jam - ContentProviders - Udacity Lesson 4bPaul Blundell
 
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4a
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4aAndroid Jam - Activity Lifecycle & Databases - Udacity Lesson 4a
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4aPaul Blundell
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationPaul Blundell
 
Jenkins project based authorization
Jenkins   project based authorizationJenkins   project based authorization
Jenkins project based authorizationPaul Blundell
 
Judge my gym - GymBabes Walkthrough
Judge my gym - GymBabes WalkthroughJudge my gym - GymBabes Walkthrough
Judge my gym - GymBabes WalkthroughPaul Blundell
 

Mehr von Paul Blundell (16)

In 10 mins a software crafting journey
In 10 mins a software crafting journeyIn 10 mins a software crafting journey
In 10 mins a software crafting journey
 
The Novoda Craft University
The Novoda Craft UniversityThe Novoda Craft University
The Novoda Craft University
 
Android Things - Solid Foundations
Android Things - Solid FoundationsAndroid Things - Solid Foundations
Android Things - Solid Foundations
 
Http Caching for the Android Aficionado
Http Caching for the Android AficionadoHttp Caching for the Android Aficionado
Http Caching for the Android Aficionado
 
My perspective on MVP and architecture discussions
My perspective on MVP and architecture discussionsMy perspective on MVP and architecture discussions
My perspective on MVP and architecture discussions
 
Java Patterns - Strategy
Java Patterns - StrategyJava Patterns - Strategy
Java Patterns - Strategy
 
Survival of the Continuist
Survival of the ContinuistSurvival of the Continuist
Survival of the Continuist
 
Google I/O 2015 Android & Tech Announcements
Google I/O 2015 Android & Tech AnnouncementsGoogle I/O 2015 Android & Tech Announcements
Google I/O 2015 Android & Tech Announcements
 
Android Jam - Services & Notifications - Udacity Lesson 6
Android Jam - Services & Notifications - Udacity Lesson 6 Android Jam - Services & Notifications - Udacity Lesson 6
Android Jam - Services & Notifications - Udacity Lesson 6
 
Android Jam - Loaders - Udacity Lesson 4c
Android Jam - Loaders - Udacity Lesson 4cAndroid Jam - Loaders - Udacity Lesson 4c
Android Jam - Loaders - Udacity Lesson 4c
 
Android Jam - ContentProviders - Udacity Lesson 4b
Android Jam - ContentProviders - Udacity Lesson 4bAndroid Jam - ContentProviders - Udacity Lesson 4b
Android Jam - ContentProviders - Udacity Lesson 4b
 
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4a
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4aAndroid Jam - Activity Lifecycle & Databases - Udacity Lesson 4a
Android Jam - Activity Lifecycle & Databases - Udacity Lesson 4a
 
Y U NO CRAFTSMAN
Y U NO CRAFTSMANY U NO CRAFTSMAN
Y U NO CRAFTSMAN
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to Mutation
 
Jenkins project based authorization
Jenkins   project based authorizationJenkins   project based authorization
Jenkins project based authorization
 
Judge my gym - GymBabes Walkthrough
Judge my gym - GymBabes WalkthroughJudge my gym - GymBabes Walkthrough
Judge my gym - GymBabes Walkthrough
 

Kürzlich hochgeladen

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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 AutomationSafe Software
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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 organizationRadu Cotescu
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Kürzlich hochgeladen (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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
 
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...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Open Closed Principle SOLID Principles Explained

  • 1. SOLID The Open/Closed Principle Dependency Inversion Paul Blundell @Blundell_apps www.blundellapps.com
  • 2. Five basic principles of object-orientated programming. “The principles when applied together intend to make it more likely that a programmer will create a system that is easy to maintain and extend over time” S ? O ? L ? I ? D ? SOLID
  • 3. Five basic principles of object-orientated programming. “The principles when applied together intend to make it more likely that a programmer will create a system that is easy to maintain and extend over time” Single Responsibility Principle Open / Closed Principle Liskov’s Substitution Interface Segregation Dependency Inversion SOLID
  • 4. Five basic principles of object-orientated programming. “The principles when applied together intend to make it more likely that a programmer will create a system that is easy to maintain and extend over time” Single Responsibility Principle Open / Closed Principle Liskov’s Substitution Interface Segregation Dependency Inversion SOLID
  • 5. Open / Closed Principle ? SOLID
  • 6. Open / Closed Principle “Software entities (classes, modules, methods etc) should be open for extension but closed for modification” That is such an entity can allow its behaviour to be changed without altering its source code. SOLID
  • 10. The aim of the OCP kata is to use the Open Closed Principle to design a maintainable and extensible code base. Think about: - How to compose functionality out of existing objects - How to avoid reworking existing code OCP Kata
  • 11. Write the first failing test Then write a factory that returns an object or a composed object that makes the test pass. Rules: - the factory should be limited to creating and linking objects - no conditionals allowed in the factory OCP Kata
  • 12. @Test public void scoreZeroForGutterGame() { // First test } @Test public void scoreTwentyForAllOnesGame() { // Second test } // Continue Bowling OCP Kata
  • 13. Write the next failing test Can you make this test pass by just changing the factory and object composite? Yes - Great do it! No - Refactor until you can The refactoring should be the system to a state where it’s possible to implement the next test just by changing the composite of objects that is returned by the factory. Do not implement new functionality when refactoring the current test must still fail. OCP Kata
  • 14. Fork / Clone this repo: git@github.com:novoda/dojos.git Goto this folder: github.com/novoda/dojos/tree/master/ocpBowling Make a copy of this folder (rename default with a team name): github.com/novoda/dojos/tree/master/ocpBowling/20130918-default Rules are in the repo here: ocpBowling/20130918-default/src/main/java/com/bowling/bowling_rules.txt Start! OCP Kata
  • 15. Matteo Vaccari - invented the OCP Kata - http://matteo.vaccari.name/blog/archives/293 David Nicolette - created the OCP jigsaw diagram Uncle Bob - Creator of the original bowling Kata - http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata Kevin Rutherford - guided me in the art of Kata’s - http://silkandspinach.net/ Jonas Gauffin - for the meme - http://blog.gauffin.org/2012/05/solid-principles-with-real-world-examples/#.UjWDy9K_s2k Credits Paul Blundell @Blundell_apps www.blundellapps.com