Exploration and Practice of Code Commenting Based on Prompt Engineering
This paper investigates the application of code comment generation technology based on Prompt Engineering in software development. With the increasing scale and complexity of software projects, traditional manual code commenting methods face issues of low efficiency and unstable quality. To address these challenges, we employ Prompt Engineering to design precise prompts that guide Large Language Models (LLMs) to automatically generate high-quality code comments. In this paper, we primarily utilized ChatGPT-4 and designed a code comment generation process for C language code based on Prompt Engineering. The experimental validation shows that this method is highly efficient in generating accurate and consistent comments. Additionally, this proposed approach has been applied to parse comments for erroneous code, assisting developers in quickly locating and fixing problems. The experimental results demonstrate that the method based on Prompt Engineering can significantly enhance the quality of code comments and development efficiency. It also provides new ideas and tools for software development and programming education.
Authors
- Yanhuai Ding (ORCID: https://orcid.org/0000-0003-1176-6397)
- Bingshu Wang (ORCID: https://orcid.org/0000-0002-2603-8328)
- Han Zhang (ORCID: https://orcid.org/0000-0001-7750-0028)
- Shuyi Li (ORCID: https://orcid.org/0000-0001-6264-9006)
Institutions
- Northwestern Polytechnical University (CN)
- Beijing University of Technology (CN)
Publication Details
- Published
- 2025-04-18
- DOI
- https://doi.org/10.1109/cste64638.2025.11092128
- Primary Topic
- Educational Technology and Assessment
- Type
- article
- Field-Weighted Citation Impact
- 0.00
Funders
- Northwestern Polytechnical University