Uncategorized

What is considered dead code?

Posted on


In some areas of computer programming, dead code is a section in the source code of a program which is executed but whose result is never used in any other computation. The execution of dead code wastes computation time and memory.

What is an example of dead code?

A return statement can be used to make dead code. Here is an example: int div_0(double a, double b) { if (b == 0) return 1; else return 0; return a/b; // dead code here. }

How do you find the dead code?

The quickest way to find dead code is to use a good IDE. Delete unused code and unneeded files. In the case of an unnecessary class, Inline Class or Collapse Hierarchy can be applied if a subclass or superclass is used. To remove unneeded parameters, use Remove Parameter.

What causes dead code?

Dead code is the part of your application that can never be executed. Common causes include: Programming errors in conditional branches. Code that will never be reached because the input data will never cause a specific branch to be executed.

Most Popular

Exit mobile version