Dead Code Removal via Service Dependency Graphs

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing methods struggle to accurately identify and remove dead code from computer programs, particularly when it serves multiple services, as they often fail to distinguish between reachable and unreachable dead code, leading to potential errors and complexity.

Innovation Solution

A method and system that utilize static and dynamic dependencies to construct a dependencies graph, classify classes, detect external-dead-class candidates, and remove them from the code, ensuring careful identification and removal of dead code without affecting the functionality of the service.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If code analysis tools are used to detect theoretically unreachable dead-code, then dead code detection capability is improved, but difficulty in distinguishing dead-code within reachable code increases

Engineering Contradiction:
Improvedead code detection capabilityVSAvoiddifficulty in distinguishing dead-code within reachable code
Core Design Contradiction:
Measurement precisionVSDifficulty of detecting and measuring

Solution Approach 1:

The patent segments the code base into service-specific code and shared code by constructing a service dependency graph. This segmentation allows the system to focus dead code analysis on service-specific code while excluding shared code that may be used across multiple services, thereby improving detection precision without increasing difficulty in distinguishing reachable dead code.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent introduces a service dependency graph as an intermediary structure to mediate between the code base and dead code detection. This graph serves as a filter that identifies which code segments are exclusive to a particular service, enabling more accurate dead code detection by providing context about code reachability and service boundaries.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Device complexity

If dead code removal is performed to reduce complexity, then code complexity is reduced, but risk of introducing errors increases

Engineering Contradiction:
Improvecode complexityVSAvoidrisk of introducing errors
Core Design Contradiction:
Device complexityVSReliability

Solution Approach 1:

The patent performs preliminary classification of code into service-specific and shared categories before dead code removal. By pre-identifying which code segments are exclusive to a service through the service dependency graph, the system can safely remove dead code from service-specific segments while preserving shared code that may be actively used elsewhere, thus reducing complexity without introducing errors.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent employs feedback mechanisms by continuously referencing the service dependency graph during dead code identification and removal. This feedback ensures that removal decisions are based on accurate information about code reachability and service boundaries, allowing the system to reduce complexity while maintaining reliability through informed, context-aware removal decisions.

Inventive Principle:
Principle #23Feedback

3Loss of substance

If code serving multiple services is removed to eliminate dead code, then dead code is reduced, but functionality of applicable service may be affected

Engineering Contradiction:
Improvedead code reductionVSAvoidfunctionality of applicable service
Core Design Contradiction:
Loss of substanceVSReliability

Solution Approach 1:

The patent segments the code base into service-specific code and shared code using the service dependency graph. This segmentation enables the system to identify and remove dead code only from service-specific segments, while automatically preserving shared code segments that are referenced by multiple services, thus eliminating dead code without affecting service functionality.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent recognizes that shared code segments serve multiple services simultaneously. By identifying these universal code segments through the service dependency graph, the system applies a protection mechanism that prevents their removal even if they appear unused in a single service context, thereby maintaining the multi-functional utility of shared code while still removing service-specific dead code.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentUS11900104B2Method and system for identifying and removing dead codes from a computer program
Publication Date: 2024.02.13 VFUNCTION INC
  • US11900104B2 patent drawing
  • US11900104B2 patent drawing
  • US11900104B2 patent drawing

AI summary

A system and method for identifying and removing dead-code from a computer program of an independent service is provided. The method includes: retrieving information related to the code of the service, wherein the retrieved information includes at least static and dynamic dependencies information of classes of the service; constructing a static dependencies graph, wherein nodes of the static dependencies graph are classes, and directed edges depict static dependencies between classes; classifying classes based on the static dependencies; constructing a first subgraph to include classes classified as internal-pure-static (IPS) classes; detecting external-dead-class candidates by traversing the subgraph; adding external-dead-class candidates to a dead code cut (DCC) set; and removing at least one class included in the DCC set from the code of the service.