code-quality

Four Types of Duplication in Source Code

We all know about DRY but time and again we can find duplication in our code. Here we talk about four types of duplication: imposed, inadvertent, impatient and interdeveloper.

Four Types of Duplication in Source Code
  1. Imposed duplication: Developer feel they have no choice - the environment seems to require duplication.

  2. Inadvertent duplication: Developers don’t realize that they are duplicating information.

  3. Impatient duplication: Developer get lazy and duplicate because it seems easier. Every project has time pressures - forces that can drive the best of us to take shortcuts. Need a function similar to one you’ve written? You’ll be tempted to copy the original and make a few changes, who has got a time to refactor and remove duplication? If you feel this temptation, remember the hackneyed aphorism “short cut make for long delays.” You may well save some seconds now, but at the potential loss of hours later.

  4. Interdeveloper duplication: Multiple people on a team duplicate a piece of information. This is perhaps the hardest type of duplication to detect and handle that occurs between different developers on a project.

Compiled from the book “The Pragmatic Programmer” by Andrew Hunt and David Thomas. You can find detailed content in chapter 2 under subtopic “The Evils of Duplication”

About the author

Prakash Poudel Sharma

Engineering Manager · Product Owner · Varicon

Engineering Manager at Varicon, leading the Onboarding squad as Product Owner. Eleven years of building software — first as a programmer, then as a founder, now sharpening the product craft from the inside of a focused team.

Keep reading

More on this

Comments