SlideShare une entreprise Scribd logo
1  sur  14
Avoid Code Duplication!
  Principles & Patterns

          Lars-Erik Kindblad
           Senior Consultant
          Blog: kindblad.com
Agenda

 Why avoid code duplication?
 Principles and patterns:
  Extract Method Principle
  Inheritance Principle
  Execute Around Method Pattern
Why avoid code duplication?

 “The way you get programmer productivity is by eliminating the lines of
  code you have to write” – Steve Jobs

 How? Stop duplicating and repeating code! Less Code to Write = Less
  Code to Maintain = More features delivered = More productive
 We normalize databases – should also normalize our code
 DRY – Don’t repeat yourself – Single Source of Truth
Extract Method Principle: Example


                                    Duplicated Code
Extract Method Principle: Example


              Extract the code to a new method
Extract Method Principle: Example


              Refactored to call the new method
Inheritance Principle: Example


                  Duplicated Code
Inheritance Principle: Example


            Refactored to a common base class
Execute Around Method Pattern: Example


                       Duplicated Code
Execute Around Method Pattern: Example

         Refactored to a new execute around method
Execute Around Method Pattern: Example


             Refactored to use the new method
Execute Around Method Pattern: Example


                 Or:
About Capgemini
With more than 120,000 people in 40 countries, Capgemini is one
of the world's foremost providers of consulting, technology and
outsourcing services. The Group reported 2011 global revenues
of EUR 9.7 billion.
Together with its clients, Capgemini creates and delivers
business and technology solutions that fit their needs and drive
the results they want. A deeply multicultural organization,
Capgemini has developed its own way of working, the
Collaborative Business ExperienceTM, and draws on Rightshore ®,
its worldwide delivery model.

Rightshore® is a trademark belonging to Capgemini
                                                                   www.capgemini.com

                                                                    The information contained in this presentation is proprietary.
                                                                                         © 2012 Capgemini. All rights reserved.

Contenu connexe

Tendances

Pitch deck Guide By Nirdesh Dwa
Pitch deck Guide By Nirdesh DwaPitch deck Guide By Nirdesh Dwa
Pitch deck Guide By Nirdesh DwaNirdesh Dwa
 
Style gan2 review
Style gan2 reviewStyle gan2 review
Style gan2 reviewtaeseon ryu
 
IRJET- Ship Detection for Pre-Annotated Ship Dataset in Machine Learning ...
IRJET-  	  Ship Detection for Pre-Annotated Ship Dataset in Machine Learning ...IRJET-  	  Ship Detection for Pre-Annotated Ship Dataset in Machine Learning ...
IRJET- Ship Detection for Pre-Annotated Ship Dataset in Machine Learning ...IRJET Journal
 
Avihu Efrat's Viola and Jones face detection slides
Avihu Efrat's Viola and Jones face detection slidesAvihu Efrat's Viola and Jones face detection slides
Avihu Efrat's Viola and Jones face detection slideswolf
 
[DDC 2018] 제조분야 AI/ML 적용 사례 (Bistel, 김현진)
[DDC 2018] 제조분야 AI/ML 적용 사례 (Bistel, 김현진)[DDC 2018] 제조분야 AI/ML 적용 사례 (Bistel, 김현진)
[DDC 2018] 제조분야 AI/ML 적용 사례 (Bistel, 김현진)Metatron
 
Professional Services for Cyber Recovery .pptx
Professional Services for Cyber Recovery .pptxProfessional Services for Cyber Recovery .pptx
Professional Services for Cyber Recovery .pptxssusercc05cf
 
VIRTUS 1.6 MSI.pdf
VIRTUS 1.6 MSI.pdfVIRTUS 1.6 MSI.pdf
VIRTUS 1.6 MSI.pdfFbioVieira85
 
Design Thinking for Social Innovation
Design Thinking for Social InnovationDesign Thinking for Social Innovation
Design Thinking for Social InnovationGreenlights
 
Image Translation with GAN
Image Translation with GANImage Translation with GAN
Image Translation with GANJunho Cho
 
Cyber-Security-Unit-1.pptx
Cyber-Security-Unit-1.pptxCyber-Security-Unit-1.pptx
Cyber-Security-Unit-1.pptxTikdiPatel
 
Semantic Segmentation Methods using Deep Learning
Semantic Segmentation Methods using Deep LearningSemantic Segmentation Methods using Deep Learning
Semantic Segmentation Methods using Deep LearningSungjoon Choi
 
Snapchat Usability Testing
Snapchat Usability TestingSnapchat Usability Testing
Snapchat Usability Testingtahreemsaleem
 
UMLtoNoSQL : From UML domain models to NoSQL Databases
UMLtoNoSQL : From UML domain models to NoSQL DatabasesUMLtoNoSQL : From UML domain models to NoSQL Databases
UMLtoNoSQL : From UML domain models to NoSQL DatabasesJordi Cabot
 
MINI PROJECT 2023 deepfake detection.pptx
MINI PROJECT 2023 deepfake detection.pptxMINI PROJECT 2023 deepfake detection.pptx
MINI PROJECT 2023 deepfake detection.pptxswathiravishankar3
 
220206 transformer interpretability beyond attention visualization
220206 transformer interpretability beyond attention visualization220206 transformer interpretability beyond attention visualization
220206 transformer interpretability beyond attention visualizationtaeseon ryu
 

Tendances (20)

Pitch deck Guide By Nirdesh Dwa
Pitch deck Guide By Nirdesh DwaPitch deck Guide By Nirdesh Dwa
Pitch deck Guide By Nirdesh Dwa
 
Style gan2 review
Style gan2 reviewStyle gan2 review
Style gan2 review
 
IRJET- Ship Detection for Pre-Annotated Ship Dataset in Machine Learning ...
IRJET-  	  Ship Detection for Pre-Annotated Ship Dataset in Machine Learning ...IRJET-  	  Ship Detection for Pre-Annotated Ship Dataset in Machine Learning ...
IRJET- Ship Detection for Pre-Annotated Ship Dataset in Machine Learning ...
 
Deep fakes and beyond
Deep fakes and beyondDeep fakes and beyond
Deep fakes and beyond
 
Zero Trust Model
Zero Trust ModelZero Trust Model
Zero Trust Model
 
Avihu Efrat's Viola and Jones face detection slides
Avihu Efrat's Viola and Jones face detection slidesAvihu Efrat's Viola and Jones face detection slides
Avihu Efrat's Viola and Jones face detection slides
 
[DDC 2018] 제조분야 AI/ML 적용 사례 (Bistel, 김현진)
[DDC 2018] 제조분야 AI/ML 적용 사례 (Bistel, 김현진)[DDC 2018] 제조분야 AI/ML 적용 사례 (Bistel, 김현진)
[DDC 2018] 제조분야 AI/ML 적용 사례 (Bistel, 김현진)
 
Professional Services for Cyber Recovery .pptx
Professional Services for Cyber Recovery .pptxProfessional Services for Cyber Recovery .pptx
Professional Services for Cyber Recovery .pptx
 
VIRTUS 1.6 MSI.pdf
VIRTUS 1.6 MSI.pdfVIRTUS 1.6 MSI.pdf
VIRTUS 1.6 MSI.pdf
 
Design Thinking for Social Innovation
Design Thinking for Social InnovationDesign Thinking for Social Innovation
Design Thinking for Social Innovation
 
Image Translation with GAN
Image Translation with GANImage Translation with GAN
Image Translation with GAN
 
Cyber-Security-Unit-1.pptx
Cyber-Security-Unit-1.pptxCyber-Security-Unit-1.pptx
Cyber-Security-Unit-1.pptx
 
Autoencoders
AutoencodersAutoencoders
Autoencoders
 
Semantic Segmentation Methods using Deep Learning
Semantic Segmentation Methods using Deep LearningSemantic Segmentation Methods using Deep Learning
Semantic Segmentation Methods using Deep Learning
 
Snapchat Usability Testing
Snapchat Usability TestingSnapchat Usability Testing
Snapchat Usability Testing
 
Adversarial training Basics
Adversarial training BasicsAdversarial training Basics
Adversarial training Basics
 
UMLtoNoSQL : From UML domain models to NoSQL Databases
UMLtoNoSQL : From UML domain models to NoSQL DatabasesUMLtoNoSQL : From UML domain models to NoSQL Databases
UMLtoNoSQL : From UML domain models to NoSQL Databases
 
Whitman_Ch10.pptx
Whitman_Ch10.pptxWhitman_Ch10.pptx
Whitman_Ch10.pptx
 
MINI PROJECT 2023 deepfake detection.pptx
MINI PROJECT 2023 deepfake detection.pptxMINI PROJECT 2023 deepfake detection.pptx
MINI PROJECT 2023 deepfake detection.pptx
 
220206 transformer interpretability beyond attention visualization
220206 transformer interpretability beyond attention visualization220206 transformer interpretability beyond attention visualization
220206 transformer interpretability beyond attention visualization
 

En vedette

Android coding standard
Android coding standard Android coding standard
Android coding standard Rakesh Jha
 
Responsive Design - Quick & Dirty
Responsive Design - Quick & DirtyResponsive Design - Quick & Dirty
Responsive Design - Quick & DirtyArno Selhorst
 
Webinar: Responsive Design
Webinar: Responsive DesignWebinar: Responsive Design
Webinar: Responsive Designkuehlhaus AG
 
Unit Tests are Overrated (NDCOslo 2013)
Unit Tests are Overrated (NDCOslo 2013)Unit Tests are Overrated (NDCOslo 2013)
Unit Tests are Overrated (NDCOslo 2013)Lars-Erik Kindblad
 
Dependency Injection vs Service Locator - Best Practice
Dependency Injection vs Service Locator - Best PracticeDependency Injection vs Service Locator - Best Practice
Dependency Injection vs Service Locator - Best PracticeLars-Erik Kindblad
 
Introduction to FluentData - The Micro ORM
Introduction to FluentData - The Micro ORMIntroduction to FluentData - The Micro ORM
Introduction to FluentData - The Micro ORMLars-Erik Kindblad
 
Application Architecture by Lars-Erik Kindblad, Capgemini
Application Architecture by Lars-Erik Kindblad, CapgeminiApplication Architecture by Lars-Erik Kindblad, Capgemini
Application Architecture by Lars-Erik Kindblad, CapgeminiLars-Erik Kindblad
 
How to build more reliable, robust and scalable distributed systems
How to build more reliable, robust and scalable distributed systemsHow to build more reliable, robust and scalable distributed systems
How to build more reliable, robust and scalable distributed systemsLars-Erik Kindblad
 
Application Architecture April 2014
Application Architecture April 2014Application Architecture April 2014
Application Architecture April 2014Lars-Erik Kindblad
 
Anforderungsanalyse und UML Grundlagen
Anforderungsanalyse und UML GrundlagenAnforderungsanalyse und UML Grundlagen
Anforderungsanalyse und UML GrundlagenChristian Baranowski
 
Domain Driven Design und Nosql
Domain Driven Design und Nosql Domain Driven Design und Nosql
Domain Driven Design und Nosql ArangoDB Database
 
Mobile Patterns - Wie Apps und Co. digitale Interfaces revolutionieren
Mobile Patterns - Wie Apps und Co. digitale Interfaces revolutionierenMobile Patterns - Wie Apps und Co. digitale Interfaces revolutionieren
Mobile Patterns - Wie Apps und Co. digitale Interfaces revolutionierenMarkus Greve
 
The Single Responsibility Principle
The Single Responsibility PrincipleThe Single Responsibility Principle
The Single Responsibility PrincipleLars-Erik Kindblad
 
Publish & Subscribe to events using an Event Aggregator
Publish & Subscribe to events using an Event AggregatorPublish & Subscribe to events using an Event Aggregator
Publish & Subscribe to events using an Event AggregatorLars-Erik Kindblad
 
Inversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best PracticeInversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best PracticeLars-Erik Kindblad
 
Domain-driven design - eine Einführung
Domain-driven design - eine EinführungDomain-driven design - eine Einführung
Domain-driven design - eine Einführungdie.agilen GmbH
 

En vedette (20)

Android coding standard
Android coding standard Android coding standard
Android coding standard
 
Responsive Design - Quick & Dirty
Responsive Design - Quick & DirtyResponsive Design - Quick & Dirty
Responsive Design - Quick & Dirty
 
Ready or not: No UI vom Verschwinden des Graphical User Interfaces
Ready or not: No UI vom Verschwinden des Graphical User InterfacesReady or not: No UI vom Verschwinden des Graphical User Interfaces
Ready or not: No UI vom Verschwinden des Graphical User Interfaces
 
Webinar: Responsive Design
Webinar: Responsive DesignWebinar: Responsive Design
Webinar: Responsive Design
 
Unit Tests are Overrated (NDCOslo 2013)
Unit Tests are Overrated (NDCOslo 2013)Unit Tests are Overrated (NDCOslo 2013)
Unit Tests are Overrated (NDCOslo 2013)
 
Dependency Injection vs Service Locator - Best Practice
Dependency Injection vs Service Locator - Best PracticeDependency Injection vs Service Locator - Best Practice
Dependency Injection vs Service Locator - Best Practice
 
Introduction to FluentData - The Micro ORM
Introduction to FluentData - The Micro ORMIntroduction to FluentData - The Micro ORM
Introduction to FluentData - The Micro ORM
 
Application Architecture by Lars-Erik Kindblad, Capgemini
Application Architecture by Lars-Erik Kindblad, CapgeminiApplication Architecture by Lars-Erik Kindblad, Capgemini
Application Architecture by Lars-Erik Kindblad, Capgemini
 
How to build more reliable, robust and scalable distributed systems
How to build more reliable, robust and scalable distributed systemsHow to build more reliable, robust and scalable distributed systems
How to build more reliable, robust and scalable distributed systems
 
Systementwurf mit UML
Systementwurf mit UMLSystementwurf mit UML
Systementwurf mit UML
 
The Fluent Interface Pattern
The Fluent Interface PatternThe Fluent Interface Pattern
The Fluent Interface Pattern
 
Application Architecture April 2014
Application Architecture April 2014Application Architecture April 2014
Application Architecture April 2014
 
Anforderungsanalyse und UML Grundlagen
Anforderungsanalyse und UML GrundlagenAnforderungsanalyse und UML Grundlagen
Anforderungsanalyse und UML Grundlagen
 
Domain Driven Design und Nosql
Domain Driven Design und Nosql Domain Driven Design und Nosql
Domain Driven Design und Nosql
 
Mobile Patterns - Wie Apps und Co. digitale Interfaces revolutionieren
Mobile Patterns - Wie Apps und Co. digitale Interfaces revolutionierenMobile Patterns - Wie Apps und Co. digitale Interfaces revolutionieren
Mobile Patterns - Wie Apps und Co. digitale Interfaces revolutionieren
 
The Single Responsibility Principle
The Single Responsibility PrincipleThe Single Responsibility Principle
The Single Responsibility Principle
 
Publish & Subscribe to events using an Event Aggregator
Publish & Subscribe to events using an Event AggregatorPublish & Subscribe to events using an Event Aggregator
Publish & Subscribe to events using an Event Aggregator
 
Inversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best PracticeInversion of Control - Introduction and Best Practice
Inversion of Control - Introduction and Best Practice
 
Data Access - Best Practice
Data Access - Best PracticeData Access - Best Practice
Data Access - Best Practice
 
Domain-driven design - eine Einführung
Domain-driven design - eine EinführungDomain-driven design - eine Einführung
Domain-driven design - eine Einführung
 

Similaire à Avoid Code Duplication with Principles & Patterns

The Product Manager Pathfinder - AIPMM Presentation - ProductCamp SV Spring 2012
The Product Manager Pathfinder - AIPMM Presentation - ProductCamp SV Spring 2012The Product Manager Pathfinder - AIPMM Presentation - ProductCamp SV Spring 2012
The Product Manager Pathfinder - AIPMM Presentation - ProductCamp SV Spring 2012Hector Del Castillo, CPM, CPMM
 
SLADE 2013 pre-Congress 10-09-2012
SLADE 2013 pre-Congress 10-09-2012SLADE 2013 pre-Congress 10-09-2012
SLADE 2013 pre-Congress 10-09-2012ldduval
 
Cloud Transformation: A Pragmatic Approach
Cloud Transformation: A Pragmatic ApproachCloud Transformation: A Pragmatic Approach
Cloud Transformation: A Pragmatic ApproachCapgemini
 
Managerial economics ppt @ mba 2009
Managerial economics ppt @ mba 2009Managerial economics ppt @ mba 2009
Managerial economics ppt @ mba 2009Babasab Patil
 
Managerial economics ppt @ mba 2009
Managerial economics ppt @ mba 2009Managerial economics ppt @ mba 2009
Managerial economics ppt @ mba 2009Babasab Patil
 
7 ways to future-proof your company
7 ways to future-proof your company7 ways to future-proof your company
7 ways to future-proof your companyBundl
 
How SAP Uses Website Testing to Drive Business Value
How SAP Uses Website Testing to Drive Business ValueHow SAP Uses Website Testing to Drive Business Value
How SAP Uses Website Testing to Drive Business ValueAdobe
 
twago @ Maastricht week of entrepreneurship
twago @ Maastricht week of entrepreneurshiptwago @ Maastricht week of entrepreneurship
twago @ Maastricht week of entrepreneurshipGunnar Berning
 
Innovation for the Future, Željko Vujinović
Innovation for the Future, Željko VujinovićInnovation for the Future, Željko Vujinović
Innovation for the Future, Željko VujinovićIBMSERBIA
 
Dutch entrepreneurs visiting twago in Berlin
Dutch entrepreneurs visiting twago in BerlinDutch entrepreneurs visiting twago in Berlin
Dutch entrepreneurs visiting twago in BerlinGunnar Berning
 
Corporate Presentation R3
Corporate Presentation R3Corporate Presentation R3
Corporate Presentation R3Troy Baker
 
Open Innovation: What's behind the buzzword?
Open Innovation:  What's behind the buzzword?Open Innovation:  What's behind the buzzword?
Open Innovation: What's behind the buzzword?SAP Ariba
 
Leading them on – secrets of successful lead nurturing programmes - The Marke...
Leading them on – secrets of successful lead nurturing programmes - The Marke...Leading them on – secrets of successful lead nurturing programmes - The Marke...
Leading them on – secrets of successful lead nurturing programmes - The Marke...B2B Marketing
 
Digital manufacturing cwin18 mexico
Digital manufacturing cwin18 mexicoDigital manufacturing cwin18 mexico
Digital manufacturing cwin18 mexicoCapgemini
 
Developing your business idea
Developing your business ideaDeveloping your business idea
Developing your business ideaMarc Parham
 
eFolder Partner Chat_How to Do Lunch and Learns
eFolder Partner Chat_How to Do Lunch and LearnseFolder Partner Chat_How to Do Lunch and Learns
eFolder Partner Chat_How to Do Lunch and LearnsDropbox
 

Similaire à Avoid Code Duplication with Principles & Patterns (20)

The Product Manager Pathfinder - AIPMM Presentation - ProductCamp SV Spring 2012
The Product Manager Pathfinder - AIPMM Presentation - ProductCamp SV Spring 2012The Product Manager Pathfinder - AIPMM Presentation - ProductCamp SV Spring 2012
The Product Manager Pathfinder - AIPMM Presentation - ProductCamp SV Spring 2012
 
SLADE 2013 pre-Congress 10-09-2012
SLADE 2013 pre-Congress 10-09-2012SLADE 2013 pre-Congress 10-09-2012
SLADE 2013 pre-Congress 10-09-2012
 
Developing your business idea
Developing your business ideaDeveloping your business idea
Developing your business idea
 
Cloud Transformation: A Pragmatic Approach
Cloud Transformation: A Pragmatic ApproachCloud Transformation: A Pragmatic Approach
Cloud Transformation: A Pragmatic Approach
 
Managerial economics ppt @ mba 2009
Managerial economics ppt @ mba 2009Managerial economics ppt @ mba 2009
Managerial economics ppt @ mba 2009
 
Managerial economics ppt @ mba 2009
Managerial economics ppt @ mba 2009Managerial economics ppt @ mba 2009
Managerial economics ppt @ mba 2009
 
7 ways to future-proof your company
7 ways to future-proof your company7 ways to future-proof your company
7 ways to future-proof your company
 
How SAP Uses Website Testing to Drive Business Value
How SAP Uses Website Testing to Drive Business ValueHow SAP Uses Website Testing to Drive Business Value
How SAP Uses Website Testing to Drive Business Value
 
twago @ Maastricht week of entrepreneurship
twago @ Maastricht week of entrepreneurshiptwago @ Maastricht week of entrepreneurship
twago @ Maastricht week of entrepreneurship
 
Capgemini
CapgeminiCapgemini
Capgemini
 
Innovation for the Future, Željko Vujinović
Innovation for the Future, Željko VujinovićInnovation for the Future, Željko Vujinović
Innovation for the Future, Željko Vujinović
 
Aca Talent
Aca TalentAca Talent
Aca Talent
 
Dutch entrepreneurs visiting twago in Berlin
Dutch entrepreneurs visiting twago in BerlinDutch entrepreneurs visiting twago in Berlin
Dutch entrepreneurs visiting twago in Berlin
 
Corporate Presentation R3
Corporate Presentation R3Corporate Presentation R3
Corporate Presentation R3
 
Open Innovation: What's behind the buzzword?
Open Innovation:  What's behind the buzzword?Open Innovation:  What's behind the buzzword?
Open Innovation: What's behind the buzzword?
 
Leading them on – secrets of successful lead nurturing programmes - The Marke...
Leading them on – secrets of successful lead nurturing programmes - The Marke...Leading them on – secrets of successful lead nurturing programmes - The Marke...
Leading them on – secrets of successful lead nurturing programmes - The Marke...
 
Digital manufacturing cwin18 mexico
Digital manufacturing cwin18 mexicoDigital manufacturing cwin18 mexico
Digital manufacturing cwin18 mexico
 
Developing your business idea
Developing your business ideaDeveloping your business idea
Developing your business idea
 
eFolder Partner Chat_How to Do Lunch and Learns
eFolder Partner Chat_How to Do Lunch and LearnseFolder Partner Chat_How to Do Lunch and Learns
eFolder Partner Chat_How to Do Lunch and Learns
 
No Cost Product Training
No Cost Product TrainingNo Cost Product Training
No Cost Product Training
 

Dernier

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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 Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
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
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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 Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
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...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
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
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Avoid Code Duplication with Principles & Patterns

  • 1. Avoid Code Duplication! Principles & Patterns Lars-Erik Kindblad Senior Consultant Blog: kindblad.com
  • 2. Agenda  Why avoid code duplication?  Principles and patterns:  Extract Method Principle  Inheritance Principle  Execute Around Method Pattern
  • 3. Why avoid code duplication?  “The way you get programmer productivity is by eliminating the lines of code you have to write” – Steve Jobs  How? Stop duplicating and repeating code! Less Code to Write = Less Code to Maintain = More features delivered = More productive  We normalize databases – should also normalize our code  DRY – Don’t repeat yourself – Single Source of Truth
  • 4. Extract Method Principle: Example Duplicated Code
  • 5. Extract Method Principle: Example Extract the code to a new method
  • 6. Extract Method Principle: Example Refactored to call the new method
  • 8. Inheritance Principle: Example Refactored to a common base class
  • 9. Execute Around Method Pattern: Example Duplicated Code
  • 10. Execute Around Method Pattern: Example Refactored to a new execute around method
  • 11. Execute Around Method Pattern: Example Refactored to use the new method
  • 12. Execute Around Method Pattern: Example Or:
  • 13.
  • 14. About Capgemini With more than 120,000 people in 40 countries, Capgemini is one of the world's foremost providers of consulting, technology and outsourcing services. The Group reported 2011 global revenues of EUR 9.7 billion. Together with its clients, Capgemini creates and delivers business and technology solutions that fit their needs and drive the results they want. A deeply multicultural organization, Capgemini has developed its own way of working, the Collaborative Business ExperienceTM, and draws on Rightshore ®, its worldwide delivery model. Rightshore® is a trademark belonging to Capgemini www.capgemini.com The information contained in this presentation is proprietary. © 2012 Capgemini. All rights reserved.