arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2504.19459cs.SE
收藏

自动注释生成技术是否存在不足?探究方法依赖对代码理解的影响

Do Automatic Comment Generation Techniques Fall Short? Exploring the Influence of Method Dependencies on Code Understanding

Md Mustakim Billah, Md Shamimur Rahman, Banani Roy

AI总结:

针对自动注释生成技术忽略方法依赖的问题,提出依赖感知技术HelpCOM,通过引入辅助方法信息提升注释质量,实验与调查证明其显著优于基线方法并增强了代码可理解性。

摘要:

方法级注释对于提升代码可理解性和支持软件维护至关重要。随着大语言模型(LLMs)的进步,自动注释生成已成为主要的研究热点。然而,现有方法常忽略方法依赖(即一个方法依赖或调用其他方法),这影响了注释质量和代码可理解性。本研究调查了软件项目中依赖方法的普遍性及影响,并提出了一种依赖感知的方法级注释生成方法。通过分析10个流行的Java GitHub项目数据集,我们发现依赖方法占所有方法的69.25%,且与独立方法相比,表现出更高的参与度和变更倾向。在448K个依赖方法和199K个独立方法中,我们观察到最先进的微调模型(如CodeT5+、CodeBERT)难以为依赖方法生成全面的注释,这一趋势在基于LLM的方法(如ASAP)中同样存在。为此,我们提出了HelpCOM,这是一种新颖的依赖感知技术,通过引入辅助方法信息来提升注释的清晰度、全面性和相关性。实验表明,HelpCOM在语法(如BLEU)、语义(如SentenceBERT)和基于LLM的评估指标上,比基线方法提升了5.6%至50.4%。对156名软件从业者的调查进一步证实,HelpCOM显著提升了涉及依赖方法的代码可理解性,凸显了其在大规模系统中增强文档、可维护性和开发者生产力的潜力。

英文摘要:

Method-level comments are critical for improving code comprehension and supporting software maintenance. With advancements in large language models (LLMs), automated comment generation has become a major research focus. However, existing approaches often overlook method dependencies, where one method relies on or calls others, affecting comment quality and code understandability. This study investigates the prevalence and impact of dependent methods in software projects and introduces a dependency-aware approach for method-level comment generation. Analyzing a dataset of 10 popular Java GitHub projects, we found that dependent methods account for 69.25% of all methods and exhibit higher engagement and change proneness compared to independent methods. Across 448K dependent and 199K independent methods, we observed that state-of-the-art fine-tuned models (e.g., CodeT5+, CodeBERT) struggle to generate comprehensive comments for dependent methods, a trend also reflected in LLM-based approaches like ASAP. To address this, we propose HelpCOM, a novel dependency-aware technique that incorporates helper method information to improve comment clarity, comprehensiveness, and relevance. Experiments show that HelpCOM outperforms baseline methods by 5.6% to 50.4% across syntactic (e.g., BLEU), semantic (e.g., SentenceBERT), and LLM-based evaluation metrics. A survey of 156 software practitioners further confirms that HelpCOM significantly improves the comprehensibility of code involving dependent methods, highlighting its potential to enhance documentation, maintainability, and developer productivity in large-scale systems.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑