Pin
Send
Share
Send


The Latin word duplication came to our language as duplication . It's about the act and the result of double : multiply something by two or double it.

For example: "To minimize traffic congestion in the downtown area, the municipal government announced the duplication of the Centenario Avenue roadway", “I have to do the duplication of the DVD as soon as possible: I don't want to lose that material for no reason", "According to several economists, the doubling of the electricity tariff will make the prices of all goods produced in the country more expensive".

It is called DNA duplication to the process that allows deoxyribonucleic acid to double, synthesizing an exact copy. This means that, from a molecule of DNA , they generate two replicas .

Also called duplication to a genetic mutation which occurs when, in the DNA sequence, one or more nucleotides are repeated. In other words, the chromosomal duplication it is a phenomenon that implies the repetition of a part of chromosome .

This mutation It occurs within the framework of DNA duplication. An erroneous overcrowding or some structural reorganization can cause the disorder. Chromosomal duplication is not seen with the naked eye: it requires molecular and cytogenetic studies.

In the field of computer programming, finally, the code duplication occurs when the same source code sequence appears more than once in the same Program . This type of sequence is called a clone and can cause various inconveniences, such as a larger file size.

Program developers consider duplication an "undesirable" situation, as it causes unnecessary complications and opposes 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, there is talk of a "similarity coincident".

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

* that are equal to one hundred percent, without exception;
* they are identical once comments and blank spaces are ignored;
* that all his 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.

Since code duplication is considered so negative by programmers, it is difficult to understand why anyone would incur this practice. It is usually associated with the action of "copy and paste ", and occurs in very neglected projects, usually in prototypes, where optimization is not sought but the achievement of results in the shortest possible time.

Programming experts criticize lazy people who make this mistake, since the style Recommended development focuses on reusing code. It is important to note that duplicate code makes it difficult for third parties to understand it, 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 want to include a tool to copy the format of a chain from text to another (each can consist of one or more characters). In general, programs of this type allow it to be done in two ways: by copying the format only once, or by keeping the associated button active to make as many copies as we wish until finally deactivating it.

In the 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 single or multiple copying. It would be a waste of space to duplicate this piece of code in each of those sections.

Pin
Send
Share
Send