Dead code removal

Reduce file sizes and save in maintenance costs by removing unnecessary dead code. Project Analyzer can reliably detect the dead code in your Visual Basic projects.

What is dead code?

Dead code means unnecessary, inoperative code that can be removed.

Dead code includes functions and sub-programs that are never called, properties that are never read or written, constants and enums that are never referenced. Variables should be both read and written to. User-defined types can also be dead and a project may contain redundant API declarations. Even entire modules and classes can be completely redundant.

The opposite of dead code is live, operational code. There are also several types of semi-dead code, that is, live-looking code and controls that are not actually required at run-time.

Why should I care about dead code?

Dead code is a very usual phenomenon. It can account for 3040% of a project's size, and increase the EXE or DLL file size by 100s of kilobytes. An average amount of dead code is 15%. The more developers, the tighter the deadlines, the older and larger the system, the more dead code.

Dead code means excessive memory use and slower execution. It also means more code to read and maintain. It leads to higher costs, especially during maintenance. If the code is in there, programmers must spend time understanding it.

Leaving dead code in a completed project means carrying untested code and hidden bugs around. Dead code may inadvertently become operative later, meaning a possible source for errors.

If you are considering the purchase of someone's source, make sure that you are not paying for hundreds of thousands of unnecessary lines. If you just took on a new project, the first thing to do should be to remove any significant dead parts. When you're finishing your newest release, remove the dead bits to ease future maintenance efforts.

Types of dead code

The following is a short list of different types of dead code. This is not a complete list. Project Analyzer supports a wide range of subtypes and special cases.

View Dead code detection in the Online Help for more accurate descriptions on each type of dead code.

Logic problems related to dead code

The following dead code related problems are classified as Logic problems in Project Analyzer. This kind of dead code is related to the execution path of a procedure. In other words, its internal logic.

How do I detect and remove dead code?

Project Analyzer (all editions) detects dead code by source code analysis. It shows how much dead and semi-dead code there is and where. Utilizing advanced analysis techniques and an extensive rule base tuned for Visual Basic and VB.NET, Project Analyzer can reliably detect dead code from live code. The analysis works reliably also with the most complex code that utilizes object-oriented techniques and late binding.

Project Analyzer Enterprise Edition makes dead code removal automatic. Its problem auto-fix feature deletes or comments out all dead code. The Enterprise Edition is also good for detecting dead code among project groups and solutions where projects call each other.

VBA Plug enables Project Analyzer to read Office VBA code and detect dead code in it. VBA Plug is optional for Project Analyzer. Read about limitations with dead VBA detection and recommended practices for dead VBA detection.

Super Project Analyzer is an optional tool to Project Analyzer. A super project is a collection of projects that share some source code files. In this setup, a piece of code may be in use in some projects, and dead in the rest. Super Project Analyzer finds code that is never called by any of the projects. Super Project Analyzer is included in the Pro and Enterprise Editions.

Beyond dead code removal: Duplicate code

Besides dead code, projects often contain duplicate code as well. Duplicate code appears because of copy & paste coding. You can decrease your programs further by eliminating the duplicated items. The following features are available in Project Analyzer:

User comments

Lance Keene, Sarbrook Company

Justin H.

Larry Marshall

Corey Alix

Spontaneous, authentic comments by real users.

Read more

Dead code detection and removal
Article about dead code. Why it happens, when to be concerned, how to detect it.

Project Analyzer
Tool that finds and removes dead code.