Dead Code is useless, but remains in the library. No other program calls such code, and no function or object references it. It is in the program, but the running state of the program has nothing to do with it.
Why is there dead code in the program? It may be a library upgrade, and old interfaces are no longer used. There may be demand adjustments, but the Code related to outdated requirements is not deleted. It may be that some useless functions are also pasted during the copy and paste process. It may be that the old code is retained for backup during the refactoring process. And so on .....
Dead Code is the code that should be deleted. Useless code, that is, Code maintained by no one. In the end, no one knows what code it is useful. Later, people began to dare not delete such code, for fear of using it wherever necessary. As a result, the accumulation of such dead code is increasing. Technical debt is getting heavier and heavier. Healthy projects slowly decay and deteriorate. No one can maintain it.
The dead code should be promptly cleared. Many programmers will worry about it. What if this code is still in use? Yes. Because you are not familiar with the Code, many people have modified the Code and may be using this code somewhere. However, we have a code protection tool: the code version control system-Git, SVN, and so on. Even if the code is deleted by mistake, it can be recovered from the history.
Most importantly, we also have automated testing. Automated testing is the most reliable guarantee to ensure that the program is correct. No matter what changes are made, add functions, and delete functions, automated tests will eventually be run to make all test points pass the green light. If you are still worried about removing dead code, it is likely that your project does not have automated testing.
If you do not delete the code, it will be very painful because no one cares about it and no one calls it. It is like a dead, zombie.
Link: http://www.vaikan.com/dead-code/