Dead Code: The Unwanted “Weed” in Programs

RSS Author RSS     Views:N/A
Bookmark and Share          Republish
Dead code is referred to a code, which, after execution, has no effect on the output of a program. It is often referred to as unreachable code (although not completely synonymous), where the program's source code cannot be executed because there is no control flow path to the code from other parts of the program. Dead code is often considered very undesirable in the software and development process.
Dead code slightly differs from unreachable code. Unreachable codes can never be reached to be executed, while dead codes are always reached and executed, but, has no effect to a program's output.
What are the causes of the existence of dead codes?
The most important phase of software product development is programming. However, when a program is written, there are occurrences of a dead code. The existence of a dead code can be due to various factors, such as:
An optimizing compiler may be responsible to internal transformations in a piece of code, thus leading to a dead code.

  • Due to complex conditional branches

  • Lack of proper program maintenance
  • Development code, which cannot function and has yet to be removed from a program.

The only way to solve the dead code problem is proper analysis. A programmer has to detect it by performing control flow analysis. He has to find any code that can never be executed regardless the values of variables at run time. Hence programmers perform a compiler optimization technique known as dead code elimination.
Programmers in an offshore software development company employ a practical approach in solving the problem of unreachable code. They use a profiler as a good heuristic to search potentially unreachable code. Once the dead code is found, a more powerful code analysis tool is used to find out whether the code is truly unreachable or not.

Report this article


Bookmark and Share
Republish



Ask a Question about this Article