Code Comment Quality Assurance via Alignment Metrics

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing systems fail to generate code comments that consistently provide a satisfactory explanation of the purpose and functionality of code segments, leading to varying quality and potential lack of comments that limit the usefulness of computer code.

Innovation Solution

A method for code comment quality assurance that involves calculating the complexity of a code portion, extracting and converting comments into text features, quantifying these features, determining alignment with the code portion, and triggering notifications for misalignment, using natural language processing and machine learning models to improve comment quality.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If existing AI systems generate code comments, then code comments can be automatically provided, but the quality and consistency of explanation are insufficient

Engineering Contradiction:
Improveautomatic code comment generationVSAvoidcomment quality and explanation accuracy
Core Design Contradiction:
ProductivityVSMeasurement precision

Solution Approach 1:

The system calculates code complexity metrics and comment quality metrics, then uses the alignment between these metrics as feedback to improve future comment generation. The alignment score feeds back into the AI system to adjust and improve the quality of generated comments over time.

Inventive Principle:
Principle #23Feedback

Solution Approach 2:

The system transforms comments into quantitative text features and compares them against code complexity parameters. By changing the parameter space from qualitative text to quantitative metrics, the system enables precise measurement and improvement of comment quality.

Inventive Principle:
Principle #35Parameter changes

2Ease of operation

If code comments are added to explain code functionality, then code readability improves, but the complexity of analyzing and ensuring comment quality increases

Engineering Contradiction:
Improvecode readabilityVSAvoidquality assurance system complexity
Core Design Contradiction:
Ease of operationVSDevice complexity

Solution Approach 1:

The system introduces an intermediary alignment metric that bridges code complexity and comment quality. This intermediary measurement simplifies the quality assurance process by providing a single metric to evaluate whether comments adequately explain the code.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The system enables code and comments to evaluate themselves through automated metric calculation. The code portion and its comments mutually assess each other's quality through the alignment metric, eliminating the need for manual external review.

Inventive Principle:
Principle #25Self-service

3Measurement precision

If code comments are analyzed and improved through alignment metrics, then comment quality increases, but the computational complexity and processing time increase

Engineering Contradiction:
Improvecomment quality measurementVSAvoidprocessing time for quality assurance
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The system focuses on measuring alignment between code and comments rather than performing exhaustive analysis of every aspect. This partial action approach provides sufficient quality assurance without requiring complete and time-consuming analysis of all code and comment properties.

Inventive Principle:
Principle #16Partial or excessive action

Data Source

PatentUS20250217136A1Code comment quality assurance
Publication Date: 2025.07.03 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US20250217136A1 patent drawing
  • US20250217136A1 patent drawing
  • US20250217136A1 patent drawing

AI summary

Code comment quality assurance includes calculating a complexity of a code portion extracting, from the code portion, one or more comments associated with the code portion, converting the one or more comments into a set of text features, quantifying the set of text features, determining, for the one or more comments, alignment between the one or more comments and the associated code portion using the quantifications of the set of text features and the complexity of the code portion, and triggering a notification responsive to the determination that the one or more comments and the associated code portion are misaligned.