Duplicate code

In computer programming, duplicate code is multiple occurrences of equivalent source code in a codebase. A duplicate code fragment is also known as a code clone, and the process of finding clones in source code is called clone detection. Duplicate code has multiple undesirable aspects.

Whether fragments are classified as duplicate can be subjective. Fragments that are very small – such as a single statement – are probably not classified as duplicate. Additionally, fragments that is not exactly the same text might be considered duplicate code if they match except for less important aspects such as whitespace, comments and variable names. Even fragments that are only functionally equivalent may be classified as duplicate.