SlideShare ist ein Scribd-Unternehmen logo
1 von 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.

Weitere ähnliche Inhalte

Was ist angesagt?

ခ်စ္နည္းလမ္းပြင့္
ခ်စ္နည္းလမ္းပြင့္ခ်စ္နည္းလမ္းပြင့္
ခ်စ္နည္းလမ္းပြင့္koluzoe
 
05_Reliable UDP 구현
05_Reliable UDP 구현05_Reliable UDP 구현
05_Reliable UDP 구현noerror
 
Scanning with nmap
Scanning with nmapScanning with nmap
Scanning with nmapcommiebstrd
 
ドメイン駆動設計のための Spring の上手な使い方
ドメイン駆動設計のための Spring の上手な使い方ドメイン駆動設計のための Spring の上手な使い方
ドメイン駆動設計のための Spring の上手な使い方増田 亨
 
C# 式木 (Expression Tree) ~ LINQをより深く理解するために ~
C# 式木 (Expression Tree) ~ LINQをより深く理解するために ~C# 式木 (Expression Tree) ~ LINQをより深く理解するために ~
C# 式木 (Expression Tree) ~ LINQをより深く理解するために ~Fujio Kojima
 
Ansible Callback Plugins
Ansible Callback PluginsAnsible Callback Plugins
Ansible Callback Pluginsjtyr
 
အသစ္ေလးႏွစ္ေယာက္
အသစ္ေလးႏွစ္ေယာက္အသစ္ေလးႏွစ္ေယာက္
အသစ္ေလးႏွစ္ေယာက္babycandy007
 
ログ分析で支えるゲームパラメータ設計 #denatechcon
ログ分析で支えるゲームパラメータ設計 #denatechconログ分析で支えるゲームパラメータ設計 #denatechcon
ログ分析で支えるゲームパラメータ設計 #denatechconDeNA
 
အန္တီမမမ်ား
အန္တီမမမ်ားအန္တီမမမ်ား
အန္တီမမမ်ားbabycandy007
 
Sticky Keys to the Kingdom
Sticky Keys to the KingdomSticky Keys to the Kingdom
Sticky Keys to the KingdomDennis Maldonado
 
Redmineosaka 20 talk_crosspoints
Redmineosaka 20 talk_crosspointsRedmineosaka 20 talk_crosspoints
Redmineosaka 20 talk_crosspointsShinji Tamura
 
Swagger ではない OpenAPI Specification 3.0 による API サーバー開発
Swagger ではない OpenAPI Specification 3.0 による API サーバー開発Swagger ではない OpenAPI Specification 3.0 による API サーバー開発
Swagger ではない OpenAPI Specification 3.0 による API サーバー開発Yahoo!デベロッパーネットワーク
 
Jiraの紹介(redmineとの比較視点にて)
Jiraの紹介(redmineとの比較視点にて)Jiraの紹介(redmineとの比較視点にて)
Jiraの紹介(redmineとの比較視点にて)Hiroshi Ohnuki
 
Vuejs를이용한서비스구축
Vuejs를이용한서비스구축Vuejs를이용한서비스구축
Vuejs를이용한서비스구축Dexter Jung
 
တပင္တိုင္ကႀကိဳး
တပင္တိုင္ကႀကိဳးတပင္တိုင္ကႀကိဳး
တပင္တိုင္ကႀကိဳးbabycandy007
 
Grade 10 ICT Short Notes in Sinhala(2015)
Grade 10 ICT Short Notes in Sinhala(2015)Grade 10 ICT Short Notes in Sinhala(2015)
Grade 10 ICT Short Notes in Sinhala(2015)Mahesh Kodituwakku
 
RESTful Web アプリの設計レビューの話
RESTful Web アプリの設計レビューの話RESTful Web アプリの設計レビューの話
RESTful Web アプリの設計レビューの話Takuto Wada
 
ပန္းဦး
ပန္းဦးပန္းဦး
ပန္းဦးbabycandy007
 
10分間でわかるWordPressのファイル構成
10分間でわかるWordPressのファイル構成10分間でわかるWordPressのファイル構成
10分間でわかるWordPressのファイル構成Michiro Sakamoto
 

Was ist angesagt? (20)

ခ်စ္နည္းလမ္းပြင့္
ခ်စ္နည္းလမ္းပြင့္ခ်စ္နည္းလမ္းပြင့္
ခ်စ္နည္းလမ္းပြင့္
 
05_Reliable UDP 구현
05_Reliable UDP 구현05_Reliable UDP 구현
05_Reliable UDP 구현
 
Scanning with nmap
Scanning with nmapScanning with nmap
Scanning with nmap
 
ドメイン駆動設計のための Spring の上手な使い方
ドメイン駆動設計のための Spring の上手な使い方ドメイン駆動設計のための Spring の上手な使い方
ドメイン駆動設計のための Spring の上手な使い方
 
C# 式木 (Expression Tree) ~ LINQをより深く理解するために ~
C# 式木 (Expression Tree) ~ LINQをより深く理解するために ~C# 式木 (Expression Tree) ~ LINQをより深く理解するために ~
C# 式木 (Expression Tree) ~ LINQをより深く理解するために ~
 
Ansible Callback Plugins
Ansible Callback PluginsAnsible Callback Plugins
Ansible Callback Plugins
 
အသစ္ေလးႏွစ္ေယာက္
အသစ္ေလးႏွစ္ေယာက္အသစ္ေလးႏွစ္ေယာက္
အသစ္ေလးႏွစ္ေယာက္
 
ログ分析で支えるゲームパラメータ設計 #denatechcon
ログ分析で支えるゲームパラメータ設計 #denatechconログ分析で支えるゲームパラメータ設計 #denatechcon
ログ分析で支えるゲームパラメータ設計 #denatechcon
 
အန္တီမမမ်ား
အန္တီမမမ်ားအန္တီမမမ်ား
အန္တီမမမ်ား
 
Sticky Keys to the Kingdom
Sticky Keys to the KingdomSticky Keys to the Kingdom
Sticky Keys to the Kingdom
 
Redmineosaka 20 talk_crosspoints
Redmineosaka 20 talk_crosspointsRedmineosaka 20 talk_crosspoints
Redmineosaka 20 talk_crosspoints
 
Swagger ではない OpenAPI Specification 3.0 による API サーバー開発
Swagger ではない OpenAPI Specification 3.0 による API サーバー開発Swagger ではない OpenAPI Specification 3.0 による API サーバー開発
Swagger ではない OpenAPI Specification 3.0 による API サーバー開発
 
Jiraの紹介(redmineとの比較視点にて)
Jiraの紹介(redmineとの比較視点にて)Jiraの紹介(redmineとの比較視点にて)
Jiraの紹介(redmineとの比較視点にて)
 
Vuejs를이용한서비스구축
Vuejs를이용한서비스구축Vuejs를이용한서비스구축
Vuejs를이용한서비스구축
 
တပင္တိုင္ကႀကိဳး
တပင္တိုင္ကႀကိဳးတပင္တိုင္ကႀကိဳး
တပင္တိုင္ကႀကိဳး
 
Tools for Metaspace
Tools for MetaspaceTools for Metaspace
Tools for Metaspace
 
Grade 10 ICT Short Notes in Sinhala(2015)
Grade 10 ICT Short Notes in Sinhala(2015)Grade 10 ICT Short Notes in Sinhala(2015)
Grade 10 ICT Short Notes in Sinhala(2015)
 
RESTful Web アプリの設計レビューの話
RESTful Web アプリの設計レビューの話RESTful Web アプリの設計レビューの話
RESTful Web アプリの設計レビューの話
 
ပန္းဦး
ပန္းဦးပန္းဦး
ပန္းဦး
 
10分間でわかるWordPressのファイル構成
10分間でわかるWordPressのファイル構成10分間でわかるWordPressのファイル構成
10分間でわかるWordPressのファイル構成
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
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
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Kürzlich hochgeladen (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
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
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

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.