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

Clean Code (Robert C. Martin)
Clean Code (Robert C. Martin)Clean Code (Robert C. Martin)
Clean Code (Robert C. Martin)Yasser Veleda
 
Writing clean and maintainable code
Writing clean and maintainable codeWriting clean and maintainable code
Writing clean and maintainable codeMarko Heijnen
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean ArchitectureMattia Battiston
 
Building an Active-Active IBM MQ System
Building an Active-Active IBM MQ SystemBuilding an Active-Active IBM MQ System
Building an Active-Active IBM MQ Systemmatthew1001
 
[Gaming on AWS] AWS 위에서의 Dev & Test, 그리고 비용 - 위메이드
[Gaming on AWS] AWS 위에서의 Dev & Test, 그리고 비용 - 위메이드[Gaming on AWS] AWS 위에서의 Dev & Test, 그리고 비용 - 위메이드
[Gaming on AWS] AWS 위에서의 Dev & Test, 그리고 비용 - 위메이드Amazon Web Services Korea
 
Planejamento Estratégico Comercial - Colocando em Prática
Planejamento Estratégico Comercial - Colocando em PráticaPlanejamento Estratégico Comercial - Colocando em Prática
Planejamento Estratégico Comercial - Colocando em PráticaNorberto Almeida De Andrade
 
O que Evitar na Escrita de Criterios de Aceite
O que Evitar na Escrita de Criterios de AceiteO que Evitar na Escrita de Criterios de Aceite
O que Evitar na Escrita de Criterios de AceiteElias Nogueira
 
CQRS + Event Sourcing
CQRS + Event SourcingCQRS + Event Sourcing
CQRS + Event SourcingMike Bild
 
Project model-canvas-apresentacao
Project model-canvas-apresentacaoProject model-canvas-apresentacao
Project model-canvas-apresentacaoleopaiva217101
 
Gestão Ágil de Projetos com Scrum
Gestão Ágil de Projetos com ScrumGestão Ágil de Projetos com Scrum
Gestão Ágil de Projetos com ScrumMarcos Garrido
 
Dependency Injection in Go
Dependency Injection in GoDependency Injection in Go
Dependency Injection in GoKurtisAngelo
 

Tendances (20)

Clean Code (Robert C. Martin)
Clean Code (Robert C. Martin)Clean Code (Robert C. Martin)
Clean Code (Robert C. Martin)
 
Metodologia Ágil
Metodologia ÁgilMetodologia Ágil
Metodologia Ágil
 
Building microservices with grpc
Building microservices with grpcBuilding microservices with grpc
Building microservices with grpc
 
Writing clean and maintainable code
Writing clean and maintainable codeWriting clean and maintainable code
Writing clean and maintainable code
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean Architecture
 
Discovery kanban
Discovery kanbanDiscovery kanban
Discovery kanban
 
Blender manual
Blender manualBlender manual
Blender manual
 
Building an Active-Active IBM MQ System
Building an Active-Active IBM MQ SystemBuilding an Active-Active IBM MQ System
Building an Active-Active IBM MQ System
 
[Gaming on AWS] AWS 위에서의 Dev & Test, 그리고 비용 - 위메이드
[Gaming on AWS] AWS 위에서의 Dev & Test, 그리고 비용 - 위메이드[Gaming on AWS] AWS 위에서의 Dev & Test, 그리고 비용 - 위메이드
[Gaming on AWS] AWS 위에서의 Dev & Test, 그리고 비용 - 위메이드
 
Kanban
KanbanKanban
Kanban
 
Trabalho scrum
Trabalho scrumTrabalho scrum
Trabalho scrum
 
Planejamento Estratégico Comercial - Colocando em Prática
Planejamento Estratégico Comercial - Colocando em PráticaPlanejamento Estratégico Comercial - Colocando em Prática
Planejamento Estratégico Comercial - Colocando em Prática
 
Meça o que importa com OKR
Meça o que importa com OKRMeça o que importa com OKR
Meça o que importa com OKR
 
O que Evitar na Escrita de Criterios de Aceite
O que Evitar na Escrita de Criterios de AceiteO que Evitar na Escrita de Criterios de Aceite
O que Evitar na Escrita de Criterios de Aceite
 
CQRS + Event Sourcing
CQRS + Event SourcingCQRS + Event Sourcing
CQRS + Event Sourcing
 
Project model-canvas-apresentacao
Project model-canvas-apresentacaoProject model-canvas-apresentacao
Project model-canvas-apresentacao
 
Gestão Ágil de Projetos com Scrum
Gestão Ágil de Projetos com ScrumGestão Ágil de Projetos com Scrum
Gestão Ágil de Projetos com Scrum
 
Scrum
ScrumScrum
Scrum
 
Dependency Injection in Go
Dependency Injection in GoDependency Injection in Go
Dependency Injection in Go
 
Scrum
ScrumScrum
Scrum
 

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! 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! 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

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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
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
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
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
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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
 
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
 

Dernier (20)

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...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
+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...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
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...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

Avoid code duplication! 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.