Jump to content

Redundant code: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m See also: Redundancy is required to transmit error free data in the presence of a noisy channel
Line 23: Line 23:
*[[Unreachable code]]
*[[Unreachable code]]
*[[Software Bloat]]
*[[Software Bloat]]
*[[error correction code]]


==References==
==References==

Revision as of 00:53, 12 August 2010

Redundant code is a computer programming term for code that computes a result that has been previously computed and is currently available, thus the repeated computation of the result is redundant.[1] If redundant code can be identified then it can be eliminated, reducing the overall computational cost of the program.

Example

 int f (int x)
 {
 	int y=x*2;
 	return x*2;
 }

The second x*2 expression is redundant code and can be replaced by a reference to the variable y. Alternatively the definition int y=x*2 can instead be removed.

Alternate uses of the term

The term redundant code may also be used to described code that has any form of redundancy, such as recomputing a value that has previously been calculated and is still available, code that is never executed, or a result which is executed and not used. Redundant code may also be used to refer to code that is executed but has no effect on the output of a program – however this is usually known as dead code. A NOP might be considered to be redundant code that has been explicitly inserted to pad out the instruction stream or introduce a time delay. Identifiers that are declared but never referenced are usually termed as redundant declarations.

See also

References