Definition of

Duplication

DuplicationThe 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 Centenario Avenue road," "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 increase the prices of all goods produced in the country» .

DNA duplication is the process that allows deoxyribonucleic acid to be duplicated, synthesizing an exact copy. This means that, from one DNA molecule, two replicas are generated.

A genetic mutation that occurs when one or more nucleotides are repeated in the DNA sequence is also called duplication. Expressed another way, chromosome duplication is a phenomenon that involves the repetition of a part of the chromosome .

This mutation occurs within the framework of DNA duplication. An erroneous crossing over or a certain structural reorganization can cause the disorder. Chromosomal duplication is not observed with the naked eye: it requires molecular and cytogenetic studies.

In the field of computer programming, finally, 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 problems, such as a larger file size.

Program developers consider duplication an "undesirable" situation, since 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 "coincident similarity ."

For two code sequences to fall into the category of duplication, at least one of the following conditions must be met:

* that they 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 coherent meaning in a given programming language ) are identical;

* that the previous point is fulfilled although with certain occasional variations;

* that are identical in functionality.

DuplicationSince code duplication is viewed so negatively by programmers, it is difficult to understand why anyone would engage in this practice. It is generally associated with the " copy and paste" action, and occurs in very neglected 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 the code. It is important to note that duplicate code makes it more difficult to understand by third parties, but also by the creator himself.

Let's look at a practical example of how to avoid code duplication. Suppose we are developing a word processor and want to include a tool for copying formatting from one text string to another (each may consist of one or more characters). Generally, programs of this type allow you to do it in two ways: copying the format only once, or keeping the associated button active to make as many copies as you want until finally deactivating it.

In code, the ideal would be to 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, whether for the single copy or the multiple. It would be a waste of space to duplicate this portion of code in each of these sections.