SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
The Single Responsibility Principle
The Single Responsibility PrincipleThe Single Responsibility Principle
The Single Responsibility PrincipleLars-Erik Kindblad
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )Ahmed Emad
 
SOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSergey Karpushin
 
Solid principles
Solid principlesSolid principles
Solid principlesToan Nguyen
 
OO Design and Design Patterns in C++
OO Design and Design Patterns in C++ OO Design and Design Patterns in C++
OO Design and Design Patterns in C++ Ganesh Samarthyam
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#Aditya Kumar Rajan
 
SOLID Design Principles applied in Java
SOLID Design Principles applied in JavaSOLID Design Principles applied in Java
SOLID Design Principles applied in JavaIonut Bilica
 
Interface segregation principle
Interface segregation principleInterface segregation principle
Interface segregation principlemuhammadali0014
 
principles of object oriented class design
principles of object oriented class designprinciples of object oriented class design
principles of object oriented class designNeetu Mishra
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility PrincipleBADR
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLIDPranalee Rokde
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesSamuel Breed
 
Solid design principles
Solid design principlesSolid design principles
Solid design principlesMahmoud Asadi
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean ArchitectureBadoo
 
Object Oriented Design Principles
Object Oriented Design PrinciplesObject Oriented Design Principles
Object Oriented Design PrinciplesThang Tran Duc
 

Tendances (20)

SOLID principles
SOLID principlesSOLID principles
SOLID principles
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
The Single Responsibility Principle
The Single Responsibility PrincipleThe Single Responsibility Principle
The Single Responsibility Principle
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
SOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principles
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Solid principles
Solid principlesSolid principles
Solid principles
 
OO Design and Design Patterns in C++
OO Design and Design Patterns in C++ OO Design and Design Patterns in C++
OO Design and Design Patterns in C++
 
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 Design Principles applied in Java
SOLID Design Principles applied in JavaSOLID Design Principles applied in Java
SOLID Design Principles applied in Java
 
Interface segregation principle
Interface segregation principleInterface segregation principle
Interface segregation principle
 
principles of object oriented class design
principles of object oriented class designprinciples of object oriented class design
principles of object oriented class design
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLID
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Solid design principles
Solid design principlesSolid design principles
Solid design principles
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
Object Oriented Design Principles
Object Oriented Design PrinciplesObject Oriented Design Principles
Object Oriented Design Principles
 
Solid principles
Solid principlesSolid principles
Solid principles
 

En vedette

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
 

En vedette (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
 

Similaire à Open Closed Principle kata

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
 

Similaire à Open Closed Principle kata (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
 

Plus de 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
 

Plus de 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
 

Dernier

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
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
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
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
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
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
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Dernier (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
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
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
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...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Open Closed Principle kata

  • 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