SlideShare uma empresa Scribd logo
DRY
Agenda
● The DRY principle
● Why code duplication is bad?
● Types of duplication
● Ways to fight duplication
● WET
DRY
OR
DIE
Don't Repeat Yourself
?
“..covers topics ranging
from personal
responsibility and career
development to
architectural techniques
for keeping your code
flexible and easy to adapt
and reuse.”
The DRY Principle
Every piece of knowledge must have a single,
unambiguous, authoritative representation
within a system.
Why code duplication is bad?
● Recurring bug fixes
● More code to maintain
● Strong possibility for logical contradictions
● Information loss
● Conveys a sense of carelessness and lack of
responsibility (Broken Window Theory)
Types of duplication
● Imposed duplication
● Inadvertent duplication
● Impatient duplication
● Interdeveloper duplication
● Imposed duplication
Types of duplication
Developers feel they have no choice — the environment seems to
require duplication.
Solutions:
- Protobuf as an example for code duplication elimination.
- Swagger as an example for documentation and code duplication elimination.
● Inadvertent Duplication
Types of duplication
Developers don't realize that they are duplicating information.
Smells:
- Same nature of a change is spread across files
- Two fields that represents the same knowledge
- Two different methods to retrieve the same data
● Impatient duplication
Types of duplication
Developers get lazy and duplicate because it seems easier.
“Short cuts make long delays” (J.R.R. Tolkien)
● Interdeveloper duplication
Types of duplication
Multiple people on a team duplicate a piece of information.
Solutions:
- Strong design and architecture to express division of responsibilities.
- Good communication within a team and across teams.
- Make it easy to reuse - if it isn't easy, people won't do it.
Ways to fight duplication
● Thorough code review
● Naming, style and conventions will help
identify code duplication
WET Write Everything
Twice
We Enjoy Typing
You can ask yourself "Haven't I written this
before?" two times, but never three.
WET
● Premature optimization is evil
● Fear of DRY abstractions which does not
make sense in the domain
● Duplication is far cheaper than the wrong
abstraction (Sandy Matz)
Takeaways
Use DRY principle to enhance your coding
and code reviews skills to protect your
software.

Mais conteúdo relacionado

Mais procurados

1..Net Framework Architecture-(c#)
1..Net Framework Architecture-(c#)1..Net Framework Architecture-(c#)
1..Net Framework Architecture-(c#)
Shoaib Ghachi
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Vikash Singh
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
Spotle.ai
 
Introduction to c#
Introduction to c#Introduction to c#
Object oriented programming With C#
Object oriented programming With C#Object oriented programming With C#
Object oriented programming With C#
Youssef Mohammed Abohaty
 
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
P3 InfoTech Solutions Pvt. Ltd.
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programming
Neelesh Shukla
 
Android share preferences
Android share preferencesAndroid share preferences
Android share preferences
Ajay Panchal
 
Creating your own exception
Creating your own exceptionCreating your own exception
Creating your own exception
TharuniDiddekunta
 
Asp.net Lab manual
Asp.net Lab manualAsp.net Lab manual
Asp.net Lab manual
Tamil Dhasan
 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net framework
Then Murugeshwari
 
OOP java
OOP javaOOP java
OOP java
xball977
 
Java EE Introduction
Java EE IntroductionJava EE Introduction
Java EE Introduction
ejlp12
 
Java exception handling ppt
Java exception handling pptJava exception handling ppt
Java exception handling ppt
JavabynataraJ
 
Visula C# Programming Lecture 1
Visula C# Programming Lecture 1Visula C# Programming Lecture 1
Visula C# Programming Lecture 1
Abou Bakr Ashraf
 
Exception Handling
Exception HandlingException Handling
Exception Handling
Reddhi Basu
 
Constructors & destructors
Constructors & destructorsConstructors & destructors
Constructors & destructors
ForwardBlog Enewzletter
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
Andriy Buday
 
Exception handling
Exception handlingException handling
Exception handling
Iblesoft
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
Sanae BEKKAR
 

Mais procurados (20)

1..Net Framework Architecture-(c#)
1..Net Framework Architecture-(c#)1..Net Framework Architecture-(c#)
1..Net Framework Architecture-(c#)
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
Object oriented programming With C#
Object oriented programming With C#Object oriented programming With C#
Object oriented programming With C#
 
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programming
 
Android share preferences
Android share preferencesAndroid share preferences
Android share preferences
 
Creating your own exception
Creating your own exceptionCreating your own exception
Creating your own exception
 
Asp.net Lab manual
Asp.net Lab manualAsp.net Lab manual
Asp.net Lab manual
 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net framework
 
OOP java
OOP javaOOP java
OOP java
 
Java EE Introduction
Java EE IntroductionJava EE Introduction
Java EE Introduction
 
Java exception handling ppt
Java exception handling pptJava exception handling ppt
Java exception handling ppt
 
Visula C# Programming Lecture 1
Visula C# Programming Lecture 1Visula C# Programming Lecture 1
Visula C# Programming Lecture 1
 
Exception Handling
Exception HandlingException Handling
Exception Handling
 
Constructors & destructors
Constructors & destructorsConstructors & destructors
Constructors & destructors
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
 
Exception handling
Exception handlingException handling
Exception handling
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
 

Semelhante a DRY or die

JUG CH December 2022 - Generic or specific?
JUG CH December 2022 - Generic or specific?JUG CH December 2022 - Generic or specific?
JUG CH December 2022 - Generic or specific?
Bert Jan Schrijver
 
Tricks for Isolated Architecture in Ruby - Sergey Kukunin
Tricks for Isolated Architecture in Ruby - Sergey KukuninTricks for Isolated Architecture in Ruby - Sergey Kukunin
Tricks for Isolated Architecture in Ruby - Sergey Kukunin
Ruby Meditation
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
Bert Jan Schrijver
 
Generic or specific? Making sensible software design decisions
 Generic or specific? Making sensible software design decisions  Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
Bert Jan Schrijver
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
Bert Jan Schrijver
 
Software Design Notes
Software Design NotesSoftware Design Notes
Software Design Notes
Diego Pacheco
 
Generic or Specific? Making Sensible Software Design Decisions
Generic or Specific? Making Sensible Software Design DecisionsGeneric or Specific? Making Sensible Software Design Decisions
Generic or Specific? Making Sensible Software Design Decisions
Bert Jan Schrijver
 
Writing Clean Code
Writing Clean CodeWriting Clean Code
Writing Clean Code
Nascenia IT
 
Rouan's design principles
Rouan's design principlesRouan's design principles
Rouan's design principles
rouanw
 
The 360 Developer
The 360 DeveloperThe 360 Developer
The 360 Developer
enteritos
 
Code Smells - Refactoring
Code Smells - RefactoringCode Smells - Refactoring
Code Smells - Refactoring
Shobi P P
 
Code Smell and Refactoring
Code Smell and RefactoringCode Smell and Refactoring
Code Smell and Refactoring
kimsrung lov
 
Code Camp NYC 2017 - How to deal with everything... | Chris Ozog - Codesushi
Code Camp NYC 2017 - How to deal with everything... | Chris Ozog - Codesushi Code Camp NYC 2017 - How to deal with everything... | Chris Ozog - Codesushi
Code Camp NYC 2017 - How to deal with everything... | Chris Ozog - Codesushi
Krzysztof (Chris) Ozog
 
Agile Software Development
Agile Software DevelopmentAgile Software Development
Agile Software Development
Ahmet Bulut
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
Bert Jan Schrijver
 
Developing Better Software
Developing Better SoftwareDeveloping Better Software
Developing Better Software
Hean Hong Leong
 
Software Engineering Primer
Software Engineering PrimerSoftware Engineering Primer
Software Engineering Primer
Georg Buske
 
Finding balance of DDD while your application grows
Finding balance of DDD while your application growsFinding balance of DDD while your application grows
Finding balance of DDD while your application grows
Carolina Karklis
 
Agile Software Development.ppt
Agile Software Development.pptAgile Software Development.ppt
Agile Software Development.ppt
abdulwehab2
 
Structured Software Design
Structured Software DesignStructured Software Design
Structured Software Design
Giorgio Zoppi
 

Semelhante a DRY or die (20)

JUG CH December 2022 - Generic or specific?
JUG CH December 2022 - Generic or specific?JUG CH December 2022 - Generic or specific?
JUG CH December 2022 - Generic or specific?
 
Tricks for Isolated Architecture in Ruby - Sergey Kukunin
Tricks for Isolated Architecture in Ruby - Sergey KukuninTricks for Isolated Architecture in Ruby - Sergey Kukunin
Tricks for Isolated Architecture in Ruby - Sergey Kukunin
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Generic or specific? Making sensible software design decisions
 Generic or specific? Making sensible software design decisions  Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Software Design Notes
Software Design NotesSoftware Design Notes
Software Design Notes
 
Generic or Specific? Making Sensible Software Design Decisions
Generic or Specific? Making Sensible Software Design DecisionsGeneric or Specific? Making Sensible Software Design Decisions
Generic or Specific? Making Sensible Software Design Decisions
 
Writing Clean Code
Writing Clean CodeWriting Clean Code
Writing Clean Code
 
Rouan's design principles
Rouan's design principlesRouan's design principles
Rouan's design principles
 
The 360 Developer
The 360 DeveloperThe 360 Developer
The 360 Developer
 
Code Smells - Refactoring
Code Smells - RefactoringCode Smells - Refactoring
Code Smells - Refactoring
 
Code Smell and Refactoring
Code Smell and RefactoringCode Smell and Refactoring
Code Smell and Refactoring
 
Code Camp NYC 2017 - How to deal with everything... | Chris Ozog - Codesushi
Code Camp NYC 2017 - How to deal with everything... | Chris Ozog - Codesushi Code Camp NYC 2017 - How to deal with everything... | Chris Ozog - Codesushi
Code Camp NYC 2017 - How to deal with everything... | Chris Ozog - Codesushi
 
Agile Software Development
Agile Software DevelopmentAgile Software Development
Agile Software Development
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Developing Better Software
Developing Better SoftwareDeveloping Better Software
Developing Better Software
 
Software Engineering Primer
Software Engineering PrimerSoftware Engineering Primer
Software Engineering Primer
 
Finding balance of DDD while your application grows
Finding balance of DDD while your application growsFinding balance of DDD while your application grows
Finding balance of DDD while your application grows
 
Agile Software Development.ppt
Agile Software Development.pptAgile Software Development.ppt
Agile Software Development.ppt
 
Structured Software Design
Structured Software DesignStructured Software Design
Structured Software Design
 

Último

ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
Madan Karki
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
GauravCar
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
architagupta876
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
AjmalKhan50578
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
Roger Rozario
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
SakkaravarthiShanmug
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
Certificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi AhmedCertificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi Ahmed
Mahmoud Morsy
 

Último (20)

ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
Certificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi AhmedCertificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi Ahmed
 

DRY or die

  • 1. DRY
  • 2. Agenda ● The DRY principle ● Why code duplication is bad? ● Types of duplication ● Ways to fight duplication ● WET
  • 4. “..covers topics ranging from personal responsibility and career development to architectural techniques for keeping your code flexible and easy to adapt and reuse.”
  • 5. The DRY Principle Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
  • 6. Why code duplication is bad? ● Recurring bug fixes ● More code to maintain ● Strong possibility for logical contradictions ● Information loss ● Conveys a sense of carelessness and lack of responsibility (Broken Window Theory)
  • 7. Types of duplication ● Imposed duplication ● Inadvertent duplication ● Impatient duplication ● Interdeveloper duplication
  • 8. ● Imposed duplication Types of duplication Developers feel they have no choice — the environment seems to require duplication. Solutions: - Protobuf as an example for code duplication elimination. - Swagger as an example for documentation and code duplication elimination.
  • 9. ● Inadvertent Duplication Types of duplication Developers don't realize that they are duplicating information. Smells: - Same nature of a change is spread across files - Two fields that represents the same knowledge - Two different methods to retrieve the same data
  • 10. ● Impatient duplication Types of duplication Developers get lazy and duplicate because it seems easier. “Short cuts make long delays” (J.R.R. Tolkien)
  • 11. ● Interdeveloper duplication Types of duplication Multiple people on a team duplicate a piece of information. Solutions: - Strong design and architecture to express division of responsibilities. - Good communication within a team and across teams. - Make it easy to reuse - if it isn't easy, people won't do it.
  • 12. Ways to fight duplication ● Thorough code review ● Naming, style and conventions will help identify code duplication
  • 13. WET Write Everything Twice We Enjoy Typing You can ask yourself "Haven't I written this before?" two times, but never three.
  • 14. WET ● Premature optimization is evil ● Fear of DRY abstractions which does not make sense in the domain ● Duplication is far cheaper than the wrong abstraction (Sandy Matz)
  • 15. Takeaways Use DRY principle to enhance your coding and code reviews skills to protect your software.

Notas do Editor

  1. DIE - duplication is evil
  2. You can find PDF online of the book Summery - https://github.com/HugoMatilla/The-Pragmatic-Programmer
  3. http://wiki.c2.com/?DontRepeatYourself http://wiki.c2.com/?CloneAndModifyProgramming information loss that happens due to inability of human to remember, reproduce or transfer information accurately Copy and paste and duplicated code is information loss about similarity. OOP CodeReuse (inheritance and OnceAndOnlyOnce) helps to avoid certain problems happening with duplicated code. Those problems do not appear immediately after CopyAndPaste happens. Those problems appear only when programmer modifies one code snippet and forgets to modify another one. The key word here is forget. He forgets because he lost information about the fact that he did copy and paste. So this problem happened because of information loss about copy and paste. https://en.wikipedia.org/wiki/Broken_windows_theory
  4. Sometimes, duplication seems to be forced on us. Project standards may require documents that contain duplicated information, or documents that duplicate information in the code. Multiple target platforms each require their own programming languages, libraries, and development environments, which makes us duplicate shared definitions and procedures. Programming languages themselves require certain structures that duplicate information. We have all worked in situations where we felt powerless to avoid duplication.
  5. You may well save some seconds now, but at the potential loss of hours later.
  6. Communication within the team: Speak about solutions in dailies stand ups Everyone should do code reviews to one another Communication across teams: Go to other teams demos Internal podcasts Communicating team work to other teams, whole R&D: Code sessions Press Release Changelog Newsletter Swapping team members occasionally
  7. https://en.wikipedia.org/wiki/Don%27t_repeat_yourself#DRY_vs_WET_solutions https://dev.to/wuz/stop-trying-to-be-so-dry-instead-write-everything-twice-wet-5g33
  8. https://en.wikipedia.org/wiki/Don%27t_repeat_yourself#DRY_vs_WET_solutions https://dev.to/wuz/stop-trying-to-be-so-dry-instead-write-everything-twice-wet-5g33 https://youtu.be/8bZh5LMaSmE https://www.sandimetz.com/blog/2016/1/20/the-wrong-abstraction