Waveform-Based Source Code Comparison for Structural Matching

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current code review tools face challenges in comparing different versions of source code, particularly when functions or variables are moved or renamed, leading to difficulties in identifying matching code elements across various source code versions.

Innovation Solution

The method involves transforming source code into waveform structures that preserve syntax and logic, allowing for shape-based comparisons rather than direct textual comparisons, enabling visualization and identification of structural and behavioral similarities across code versions.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If traditional text-based code comparison methods are used, then direct textual matching can be performed, but matching accuracy deteriorates when functions or variables are moved or renamed

Engineering Contradiction:
Improvecode element matching accuracyVSAvoidability to handle code restructuring
Core Design Contradiction:
Measurement precisionVSAdaptability or versatility

Solution Approach 1:

The patent transforms source code into waveform representations where the structural and behavioral characteristics of code are converted into visual patterns. This parameter transformation allows comparison based on code behavior and structure rather than text, enabling accurate matching even when functions or variables are moved or renamed. The waveform encoding captures the essential characteristics of code execution without being tied to specific text positions or names.

Inventive Principle:
Principle #35Parameter changes

2Measurement precision

If waveform transformation is applied to preserve syntax and logic, then structural similarity identification is improved, but processing complexity increases

Engineering Contradiction:
Improvestructural similarity detection accuracyVSAvoidcode transformation and comparison system complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The patent replaces traditional text-based mechanical comparison with a waveform-based visual representation system. By converting code into waveform patterns that represent syntax and logic structure, the system enables intuitive visual analysis of code similarities. This substitution transforms the comparison mechanism from text-matching algorithms to waveform pattern recognition, improving structural similarity detection while managing complexity through visual intuition.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

Data Source

PatentUS20220188101A1Shape-based code comparisons
Publication Date: 2022.06.16 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US20220188101A1 patent drawing
  • US20220188101A1 patent drawing
  • US20220188101A1 patent drawing

AI summary

Aspects include generating a matrix based on a first sample of source code. Each cell in the matrix can correspond to a unique element in the source code. Each unique element can be encoded to a predetermined value according to an encoding rule. A first waveform is generated by combining a left-side curve and a right-side curve. The left-side curve encodes a first position of non-zero cells in each row of the matrix and the right-side curve encodes a last position of non-zero cells in each row of the matrix. A second sample of source code is identified that matches the first sample of source code based on a comparison of the first waveform to a second waveform constructed from the second sample of source code.