SlideShare une entreprise Scribd logo
1  sur  39
Implementing The Open/Closed Principle
Sam Hennessy




    • Originally from the UK
    • Now live in Denver, CO
    • Software Architect at i3logix
    • Ex-Pro Services Consultant For Zend
    • Regular at Front Range PHP Users Group


2
i3logix




3
What is it?




     Part of SOLID

     Protect your system from change

     Do you already do it?


4
SOLID


            S       Single responsibility
                          principle

            O      Open/closed principle


            L   Liskov substitution principle


            I      Interface segregation
                          principle


5
            D      Dependency inversion
                        principle
Open/Closed Principle




    "Be open for extension,
           but closed for
    modification."

6
And I Care Why?


                             Maintenance



               Let your
                                             Customer
            users bridge a
                                           customization
             feature gap




             Competitive                     Preventing
                edge                        the "FORK"!



                              A-la-cart
                               feature
                              offerings
7
What about YAGNI and KISS?




8
Where Can It Be Applied?


                               Class


                               Application


                               Enterprise




9
Classes
Classes




                         Inheritance




               Polymorphism            Interfaces




11
Small Methods




12
No Public Properties




                            Always be private?


                              Encapsulation


                            Information hiding


                             It's cheap to do


13
Globals and OCP




14
De-coupling




15
class Calculator{
    public function __invoke($calc, $left, $right) {
        if ($calc == 'add') {
            return $left + $right;
        } else if ($calc == 'sub') {
            return $left - $right;
        }
    }
}
class Calculator{
    public function __invoke(Calc $calc, $left, $right){
        return $calc($left, $right);
    }
}


$calculator = new Calculator();
echo $calculator(new AddCalc(), 2, 1), "n";
echo $calculator(new SubCalc(), 2, 1), "n";
interface Calc {
    public function __invoke($left, $right);
}


class AddCalc implements Calc {
    public function __invoke($left, $right) {
        return $left + $right;
    }
}


class SubCalc implements Calc {
    public function __invoke($left, $right) {
        return $left - $right;
    }
}
if ($logType == 'echo') {
    echo $message;
} else if ($logType == 'file') {
    $logger->writeToFile($message);
}
Composition Over Inheritance




20
Behavior vs. Dependencies




21
Application
Plugins




23
Service Locator




24
Dependency Injection




25
Event Driven Programming




26
Aspect Oriented Programming




27
Rules Engine




28
Build Process




29
Enterprise
Public API




31
Service Oriented Architecture (SOA)




32
Global Broadcast




33
When to break OCP!?
When to break OCP!?



                             Separation of
                               concerns




                Excessive                        Single
               duplication                   responsibility



35
Everyday vs. the Revolutionary




       Facts don't                      Feature
          fit the                      doesn't fit
         theory                       the design



36
What’s Your Strategy?
Questions?
Thanks You!

Contenu connexe

Tendances

Open Closed Principle kata
Open Closed Principle kataOpen Closed Principle kata
Open Closed Principle kataPaul Blundell
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design PrinciplesSteve Zhang
 
Solid design principles
Solid design principlesSolid design principles
Solid design principlesMahmoud Asadi
 
Design Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID codeDesign Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID codePaulo Gandra de Sousa
 
S.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsS.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsRicardo Wilkins
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo designConfiz
 
Object-oriented design principles
Object-oriented design principlesObject-oriented design principles
Object-oriented design principlesXiaoyan Chen
 
Principios solid con c#
Principios solid con c#Principios solid con c#
Principios solid con c#Matias Iacono
 
Writing Maintainable Software Using SOLID Principles
Writing Maintainable Software Using SOLID PrinciplesWriting Maintainable Software Using SOLID Principles
Writing Maintainable Software Using SOLID PrinciplesDoug Jones
 
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 Solid Principles
The Solid PrinciplesThe Solid Principles
The Solid PrinciplesLuke Smith
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLIDPranalee Rokde
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesSamuel Breed
 
Software Design principles
Software Design principlesSoftware Design principles
Software Design principlesMilan Ashara
 

Tendances (20)

Open Closed Principle kata
Open Closed Principle kataOpen Closed Principle kata
Open Closed Principle kata
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design Principles
 
Solid design principles
Solid design principlesSolid design principles
Solid design principles
 
Design Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID codeDesign Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID code
 
S.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsS.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software Architects
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Object-oriented design principles
Object-oriented design principlesObject-oriented design principles
Object-oriented design principles
 
Principios solid con c#
Principios solid con c#Principios solid con c#
Principios solid con c#
 
SOLID design principles applied in Java
SOLID design principles applied in JavaSOLID design principles applied in Java
SOLID design principles applied in Java
 
SOLID principles
SOLID principlesSOLID principles
SOLID principles
 
Writing Maintainable Software Using SOLID Principles
Writing Maintainable Software Using SOLID PrinciplesWriting Maintainable Software Using SOLID Principles
Writing Maintainable Software Using SOLID Principles
 
SOLID Design principles
SOLID Design principlesSOLID Design principles
SOLID Design principles
 
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 Solid Principles
The Solid PrinciplesThe Solid Principles
The Solid Principles
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLID
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Software Design principles
Software Design principlesSoftware Design principles
Software Design principles
 
SOLID principles
SOLID principlesSOLID principles
SOLID principles
 

En vedette

PHP in the Real World
PHP in the Real WorldPHP in the Real World
PHP in the Real WorldIvo Jansch
 
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job QueueTask Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job QueueSam Hennessy
 
PHP – Faster And Cheaper. Scale Vertically with IBM i
PHP – Faster And Cheaper. Scale Vertically with IBM iPHP – Faster And Cheaper. Scale Vertically with IBM i
PHP – Faster And Cheaper. Scale Vertically with IBM iSam Hennessy
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsSam Hennessy
 
Open Close Principle
Open Close PrincipleOpen Close Principle
Open Close PrincipleThaichor Seng
 
Solid principles
Solid principlesSolid principles
Solid principlesViet Vu
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility PrincipleEyal Golan
 
List of Software Development Model and Methods
List of Software Development Model and MethodsList of Software Development Model and Methods
List of Software Development Model and MethodsRiant Soft
 

En vedette (11)

PHP in the Real World
PHP in the Real WorldPHP in the Real World
PHP in the Real World
 
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job QueueTask Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
 
PHP – Faster And Cheaper. Scale Vertically with IBM i
PHP – Faster And Cheaper. Scale Vertically with IBM iPHP – Faster And Cheaper. Scale Vertically with IBM i
PHP – Faster And Cheaper. Scale Vertically with IBM i
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy Applications
 
Open Close Principle
Open Close PrincipleOpen Close Principle
Open Close Principle
 
Solid principles
Solid principlesSolid principles
Solid principles
 
jeas_0816_4883
jeas_0816_4883jeas_0816_4883
jeas_0816_4883
 
Dependency Inversion Principle
Dependency Inversion PrincipleDependency Inversion Principle
Dependency Inversion Principle
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
 
SOLID Principles part 1
SOLID Principles part 1SOLID Principles part 1
SOLID Principles part 1
 
List of Software Development Model and Methods
List of Software Development Model and MethodsList of Software Development Model and Methods
List of Software Development Model and Methods
 

Similaire à Implementing The Open/Closed Principle

2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#Daniel Fisher
 
The Single Responsibility Principle
The Single Responsibility PrincipleThe Single Responsibility Principle
The Single Responsibility PrincipleLars-Erik Kindblad
 
Code Structural Analysis
Code Structural AnalysisCode Structural Analysis
Code Structural AnalysisEduards Sizovs
 
Code Structural Analysis
Code Structural AnalysisCode Structural Analysis
Code Structural AnalysisDmitry Buzdin
 
Design principle vs design patterns
Design principle vs design patternsDesign principle vs design patterns
Design principle vs design patternsPrabhakar Sharma
 
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
 
SOLID principles-Present
SOLID principles-PresentSOLID principles-Present
SOLID principles-PresentQuang Nguyen
 
Software design principles
Software design principlesSoftware design principles
Software design principlesMd.Mojibul Hoque
 
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...JAX London
 
Bluffers guide to Terminology
Bluffers guide to TerminologyBluffers guide to Terminology
Bluffers guide to TerminologyJim Gough
 
What I learned migrating applications to the cloud - Experience SAP devX at D...
What I learned migrating applications to the cloud - Experience SAP devX at D...What I learned migrating applications to the cloud - Experience SAP devX at D...
What I learned migrating applications to the cloud - Experience SAP devX at D...Mateus Aubin
 
Clean code: SOLID (iOS)
Clean code: SOLID (iOS)Clean code: SOLID (iOS)
Clean code: SOLID (iOS)Maksym Husar
 
Use Design Principle to Improve code quality
Use Design Principle to Improve code qualityUse Design Principle to Improve code quality
Use Design Principle to Improve code qualityHebin Wei
 

Similaire à Implementing The Open/Closed Principle (20)

SOLID design
SOLID designSOLID design
SOLID design
 
2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#
 
The Single Responsibility Principle
The Single Responsibility PrincipleThe Single Responsibility Principle
The Single Responsibility Principle
 
Code Structural Analysis
Code Structural AnalysisCode Structural Analysis
Code Structural Analysis
 
Code Structural Analysis
Code Structural AnalysisCode Structural Analysis
Code Structural Analysis
 
Solid js
Solid jsSolid js
Solid js
 
Design principle vs design patterns
Design principle vs design patternsDesign principle vs design patterns
Design principle vs design patterns
 
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
 
SOLID principles-Present
SOLID principles-PresentSOLID principles-Present
SOLID principles-Present
 
Software design principles
Software design principlesSoftware design principles
Software design principles
 
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
 
Design Principles
Design PrinciplesDesign Principles
Design Principles
 
Bluffers guide to Terminology
Bluffers guide to TerminologyBluffers guide to Terminology
Bluffers guide to Terminology
 
SOLID
SOLIDSOLID
SOLID
 
What I learned migrating applications to the cloud - Experience SAP devX at D...
What I learned migrating applications to the cloud - Experience SAP devX at D...What I learned migrating applications to the cloud - Experience SAP devX at D...
What I learned migrating applications to the cloud - Experience SAP devX at D...
 
The CQRS diet
The CQRS dietThe CQRS diet
The CQRS diet
 
Solid
SolidSolid
Solid
 
Clean code: SOLID
Clean code: SOLIDClean code: SOLID
Clean code: SOLID
 
Clean code: SOLID (iOS)
Clean code: SOLID (iOS)Clean code: SOLID (iOS)
Clean code: SOLID (iOS)
 
Use Design Principle to Improve code quality
Use Design Principle to Improve code qualityUse Design Principle to Improve code quality
Use Design Principle to Improve code quality
 

Dernier

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
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
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
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
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
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
 
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
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 

Dernier (20)

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
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
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
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...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Implementing The Open/Closed Principle

Notes de l'éditeur

  1. A note
  2. I hope to enable you to add some consistency by formalizing your thinking around OCP
  3. Risk of making changeLessened by good automated testing coveragePlatforms Amazon vs. GoogleTwitter
  4. You can apply the principle reactively
  5. Let’s take a look at techniques for each layer
  6. Traditional ideas of OCP what you be able to write the class code once and never have to come back to edit itThese techniques focus on this level changeSome of my application level techniques kind of blur the linePrevent changes to a classDoesn’t prevent change to the app, unless you are using DI or something like it
  7. Small is fast when it comes to changing direction10 executable lines is a good target, 20 the max (obviously there are always exceptions)
  8. Just one client can mess it up for everyone
  9. Traditional ideas of OCP say that globals break OCPThese are points of view that are just thinking about riskYou are introducing risk that other parts of the system will break this code
  10. Making your code ignorantAbstracting – to
  11. Imagine this all over your application.Then we want to add FireBug/FirePHP logging support for our Ajax calls
  12. Also called Composite Reuse Principle
  13. What’s your goal
  14. Can anyone think of any more class level techniques
  15. Lots of examples from ZFThink how this has helped word press
  16. Signal & SlotsPub/Sub
  17. Cross cutting concernsFlow 3
  18. Can anyone think of any more APPLICATION level techniques
  19. Message bus
  20. PubsubQueueTrue broadcast
  21. Martin FowlerIsolate the assumptions scattered around the code to a single element (by assumptions, you assumed they wouldn't need to change) E.g. You are echoing all over the code, but you need to support encoding to jsonThis will reduce the risk for the big change Or start from scratch
  22. Why are you doing this?