Top "Code-duplication" questions

Code duplication, also sometimes known as code cloning, is a programming practice consisting in repeating the same (or similar) sequences of code statements within a software same project.

How can I use multiple constructors to remove duplicated code while maintaining readability?

int a, b, c; Constructor() { a = 5; b = 10; c = 15; //do stuff } Constructor(int x, int y) { a = x; b = y; c = 15; //…

c# parameters constructor this code-duplication
How do I remove code duplication between similar const and non-const member functions?

Let's say I have the following class X where I want to return access to an internal member: class Z { // …

c++ class constants code-duplication c++-faq
Suppress duplicate warnings in IntelliJ IDEA by annotation

Since version 15, IntelliJ warns me about code duplicates. In some cases this might be intentional, so I want to ignore/…

intellij-idea suppress-warnings code-duplication
How to detect code duplication during development?

We have a fairly large code base, 400K LOC of C++, and code duplication is something of a problem. Are …

c++ code-duplication
Do tools exist which automatically find copy-and-paste code?

Are there tools out there which could automatically find copy-and-paste code among a set of files? I was thinking of …

code-analysis copy-paste static-analysis code-duplication
Tortoise SVN: compare two directories (instead of files or revisions)

You can compare two revisions or files with Tortoise SVN. Is there also a way to compare two directories? I …

svn tortoisesvn diff compare code-duplication
Is duplicated code more tolerable in unit tests?

I ruined several unit tests some time ago when I went through and refactored them to make them more DRY--the …

unit-testing dry code-duplication
How much duplicated code do you tolerate?

In a recent code review I spotted a few lines of duplicated logic in a class (less than 15 lines). When …

refactoring coding-style dry code-duplication
Java multi-type method parameter?

I wonder if it is possible to require that a java method parameter is of any type from finite set …

java design-patterns code-duplication
generic code duplication detection tool

I'm looking for a code duplication tool that is language agnostic. It's easy to find language specific code duplication tools (…

language-agnostic duplicates code-analysis static-analysis code-duplication