The Latin word duplication came to our language as duplication. It is about the act and result of doubling: multiplying something by two or making it double.
For example: “To minimize traffic congestion in the downtown area, the municipal government announced the duplication of the Avenida Centenario roadway”, “I have to duplicate the DVD as soon as possible: I don’t want to lose that material for any reason ”, “According to several economists, the doubling of the electricity rate will raise the prices of all the goods produced in the country”.
DNA duplication is the process that enables deoxyribonucleic acid to duplicate, synthesizing an exact copy. This means that, from a DNA molecule, two replicas are generated.
Duplication is also called a genetic mutation that occurs when one or more nucleotides are repeated in the DNA sequence. Expressed another way, chromosome doubling is a phenomenon that involves the repetition of a part of the chromosome. According to abbreviationfinder, DOB stands for Duplication of Benefits.
This mutation occurs in the context of DNA duplication. Miscrossing or some structural rearrangement can cause the disorder. Chromosomal duplication is not observed with the naked eye: it requires molecular and cytogenetic studies.
Finally, in the field of computer programming, code duplication occurs when the same sequence of source code appears more than once in the same program. This type of sequence is called a clone and can cause various drawbacks, such as a larger file size.
Program developers consider duplication an “undesirable” situation, as it leads to unnecessary complications and is contrary to the concept of optimization. It is worth mentioning that two portions of a code file, or the code of an entire program, can be very similar without being considered clones: in these cases, we speak of a « coincidental similarity ».
In order for two code sequences to fall into the category of duplication, at least one of the following conditions must be met:
* that are equal to one hundred percent, without exception;
* that are identical once comments and whitespace are ignored;
* that all its tokens (lexical components that have a consistent meaning in a certain programming language) are identical;
* that the previous point is fulfilled although with certain occasional variations;
* that are identical in functionality.
Since code duplication is viewed as such a bad thing by programmers, it’s hard to understand why anyone would engage in this practice. It is usually associated with the action of ” copying and pasting”, and occurs in very careless projects, generally in prototypes, where optimization is not sought, but rather the achievement of results in the shortest possible time.
Programming experts criticize those who make this mistake as lazy, since the recommended development style focuses on reusing code. It is important to point out that duplicate code makes it more difficult for third parties to understand, but also for the creator himself.
Let’s look at a practical example of how to avoid code duplication. Suppose we are developing a word processor and we want to include a tool to copy the formatting from one text string to another (each string can consist of one or more characters). In general, programs of this type allow you to do it in two ways: by copying the format only once, or by keeping the associated button active to make as many copies as you want until finally deactivating it.
In the code, ideally, we would create a function in which all the steps to copy the format of a string are carried out, and then “call” it from each part of the file in which we need it, either for the single copy or the multiple. It would be a waste of space to duplicate this piece of code in each of those sections.