Affiliation:
1. School of Computer Science, Peking University and Key Laboratory of High Confidence Software Technologies, Ministry of Education, China
2. College of Information and Computer Sciences, University of Massachusetts Amherst, Amherst, MA, USA
3. Department of Computer Science, University of Illinois at Urbana-Champaign, Champaign, IL, USA
4. School of Computer Science, Peking University and Key Laboratory of HighConfidence Software Technologies, Ministry of Education, China
Abstract
High-quality source code comments are valuable for software development and maintenance, however, code often contains low-quality comments or lacks them altogether. We name such source code comments as suboptimal comments. Such suboptimal comments create challenges in code comprehension and maintenance. Despite substantial research on low-quality source code comments, empirical knowledge about commenting practices that produce suboptimal comments and reasons that lead to suboptimal comments are lacking. We help bridge this knowledge gap by investigating (1)
independent comment changes (ICCs)
—comment changes committed independently of code changes—which likely address suboptimal comments, (2) commenting guidelines, and (3) comment-checking tools and comment-generating tools, which are often employed to help commenting practice—especially to prevent suboptimal comments.
We collect 24M+ comment changes from 4,392 open-source GitHub Java repositories and find that ICCs widely exist. The
ICC ratio
—proportion of ICCs among all comment changes—is ~15.5%, with 98.7% of the repositories having ICC. Our thematic analysis of 3,533 randomly sampled ICCs provides a three-dimensional taxonomy for
what
is changed (four comment categories and 13 subcategories),
how
it changed (six commenting activity categories), and
what factors
are associated with the change (three factors). We investigate 600 repositories to understand the prevalence, content, impact, and violations of commenting guidelines. We find that only 15.5% of the 600 sampled repositories have any commenting guidelines. We provide the first taxonomy for elements in commenting guidelines: where and what to comment are particularly important. The repositories without such guidelines have a statistically significantly higher ICC ratio, indicating the negative impact of the lack of commenting guidelines. However, commenting guidelines are not strictly followed: 85.5% of checked repositories have violations. We also systematically study how developers use two kinds of tools, comment-checking tools and comment-generating tools, in the 4,392 repositories. We find that the use of
Javadoc
tool is negatively correlated with the ICC ratio, while the use of
Checkstyle
has no statistically significant correlation; the use of comment-generating tools leads to a higher ICC ratio.
To conclude, we reveal issues and challenges in current commenting practice, which help understand how suboptimal comments are introduced. We propose potential research directions on comment location prediction, comment generation, and comment quality assessment; suggest how developers can formulate commenting guidelines and enforce rules with tools; and recommend how to enhance current comment-checking and comment-generating tools.
Funder
National Key R&D Program of China
National Natural Science Foundation of China
US National Science Foundation
Publisher
Association for Computing Machinery (ACM)
Reference119 articles.
1. Hirohisa Aman, Sousuke Amasaki, Tomoyuki Yokogawa, and Minoru Kawahara. 2018. A Doc2Vec-based assessment of comments and its application to change-prone method analysis. In 2018 25th Asia-Pacific Software Engineering Conference (APSEC). IEEE, 643–647.
2. androidannotations. 2019. How To Contribute Code. https://github.com/androidannotations/androidannotations/wiki/HowToContributeCode.
3. Apache Maven Javadoc Plugin. 2022. Apache Maven Javadoc Plugin. https://maven.apache.org/plugins/maven-javadoc-plugin/index.html.
4. Oliver Arafati and Dirk Riehle. 2009. The comment density of open source software code. In 2009 31st International Conference on Software Engineering-Companion Volume. IEEE, 195–198.
5. Nikolaos Bafatakis, Niels Boecker, Wenjie Boon, Martin Cabello Salazar, Jens Krinke, Gazi Oznacar, and Robert White. 2019. Python coding style compliance on stack overflow. In 2019 IEEE/ACM 16th International Conference on Mining Software Repositories (MSR). IEEE, 210–214.
Cited by
2 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献