Duplicated or otherwise redundant code obscures intent and makes it harder to understand the logic. There are several other reasons to avoid redundant code. For example, it makes maintenance harder.
Use standard algorithms where apropriate, instead of writing some own implementation.
**See also**: [SL.1](#Rsl-lib)
##### Example
void func(bool flag) // Bad, duplicated code.
{
if (flag) {
x();
y();
}
else {
x();
z();
}
}
void func(bool flag) // Better, no duplicated code.
{
x();
if (flag)
y();
else
z();
}
##### Enforcement
* Use a static analyzer. It will catch at least some redundant constructs.
* Code review
## ES.dcl: Declarations
A declaration is a statement. A declaration introduces a name into a scope and might cause the construction of a named object.