Do Automatic Comment Generation Techniques Fall Short? Exploring the Influence of Method Dependencies on Code Understanding
Method-level comments are essential for improving code comprehension and facilitating software maintenance. With advancements in large language models (LLMs), automated comment generation has become a key focus in software development research. However,current approaches often overlook method dependencies where one method relies on or calls other methods, which impacts comment quality and code understandability. This study investigates the prevalence and characteristics of dependent methods in softwareprojects and introduces a dependency-aware approach for generating method-level comments. Using a dataset of 10 popular GitHub projects written in Java, we found that dependent methods, which comprise 69.25% of all methods, show higher engagement and frequency of change than independent ones. Using an analysis of over 448K dependent methods and 199K independent methods, we observed that state-of-the-art finetuned models, such as CodeT5+ and CodeBERT, face challenges in generating comprehensive method-level comments for dependent methods compared to independent ones. Similarly, LLM-based comment generation models, including ASAP and CodeLlama, demonstrated comparable performance trends when evaluated on a substantial sample. To address this, we propose HelpCOM, a novel dependency-aware comment generation model that incorporates helper method information to improve comment clarity, comprehensiveness, and relevance. Experimental results show that HelpCOM outperforms state-of-the-art models by 5.6% to 50.4% across syntactic (e.g., BLEU), semantic (e.g., SentenceBERT), and LLM-based evaluation metrics. Additionally, a survey of 156 software professionals confirms that HelpCOM significantly improves the comprehensibility of code involving dependent methods. These findings highlight its potential to enhance documentationpractices, code maintainability, and developer productivity in large-scale systems.
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2025-02-03
- DOI
- https://doi.org/10.5281/zenodo.14793792
- Primary Topic
- Gastrointestinal Tumor Research and Treatment
- Type
- article
- Field-Weighted Citation Impact
- 0.00