SlideShare uma empresa Scribd logo
1 de 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.

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
 
Quiery builder
Quiery builderQuiery builder
Quiery builder
 
Express JS
Express JSExpress JS
Express JS
 
Dynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEMDynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEM
 
Indexing with MongoDB
Indexing with MongoDBIndexing with MongoDB
Indexing with MongoDB
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
Angular 2 observables
Angular 2 observablesAngular 2 observables
Angular 2 observables
 
5 easy steps to understanding json web tokens (jwt)
5 easy steps to understanding json web tokens (jwt)5 easy steps to understanding json web tokens (jwt)
5 easy steps to understanding json web tokens (jwt)
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service Design
 
Meetup angular http client
Meetup angular http clientMeetup angular http client
Meetup angular http client
 
Tracing in ASp.Net
Tracing in ASp.NetTracing in ASp.Net
Tracing in ASp.Net
 
Introducing Service Discovery for Amazon ECS - CON403 - re:Invent 2017
Introducing Service Discovery for Amazon ECS - CON403 - re:Invent 2017Introducing Service Discovery for Amazon ECS - CON403 - re:Invent 2017
Introducing Service Discovery for Amazon ECS - CON403 - re:Invent 2017
 
Sap abap tutorial
Sap abap tutorialSap abap tutorial
Sap abap tutorial
 
DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFramework
 
Ajax ppt
Ajax pptAjax ppt
Ajax ppt
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
C# Parallel programming
C# Parallel programmingC# Parallel programming
C# Parallel programming
 
20. CodeIgniter edit images
20. CodeIgniter edit images20. CodeIgniter edit images
20. CodeIgniter edit images
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 

Destaque

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
 

Destaque (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
 

Semelhante a 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
 

Semelhante a 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
 

Último

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

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.