Code duplication
Code duplication is a computer programming or software engineering term for a sequence of source code that occurs more than once in a given program or collection of related programs. Code duplication makes maintenance and modification of source code harder, because if a change needs to be made to a duplicated line of code, then the same change usually needs to be made in all the places where that line was duplicated.
One common cause of code duplication in software projects is so-called copy and paste programming, in which a section of code is copied "because it works", without thinking about how the code could be refactored to allow a single code section to be reused, instead of duplicated.
The usual solution is to encapsulate the duplicated code into a library subroutine (which is modifiable) or a software component (which is not).
A number of different methods have been proposed to detect duplicate code automatically, with or without human intervention.
See also
External links
- Find duplicates in Java source
- Simian: tool supporting a variety of languages
- Visual Detection of Duplicated Code(PDF) Software Composition Group, University of Berne
- Brenda Baker of Bell Labs is a leading researcher in automatic detection of duplicate code