Premium
Does your code need comment?
Author(s) -
Huang Yuan,
Jia Nan,
Shu Junhuai,
Hu Xinyu,
Chen Xiangping,
Zhou Qiang
Publication year - 2020
Publication title -
software: practice and experience
Language(s) - English
Resource type - Journals
SCImago Journal Rank - 0.437
H-Index - 70
eISSN - 1097-024X
pISSN - 0038-0644
DOI - 10.1002/spe.2772
Subject(s) - computer science , header , source code , static program analysis , program comprehension , identification (biology) , reuse , code (set theory) , software engineering , software , code review , comprehension , software maintenance , kpi driven code analysis , programming language , data mining , software development , software system , computer network , ecology , botany , set (abstract data type) , biology
Summary Code comments convey information about the programmers' intention in a more explicit but less rigorous manner than source code. This information can assist programmers in various tasks, such as code comprehension, reuse, and maintenance. To better understand the properties of the comments existing in the source code, we analyzed more than 450 000 comments across 136 popular open‐source software systems coming different domains. We found that the methods involving header comments and internal comments were shown low percentages in software systems, ie, 4.4% and 10.27%, respectively. As an application of our findings, we propose an automatic approach to determine whether a method needs a header comment, known as commenting necessity identification. Specifically, we identify the important factors for determining the commenting necessity of a method and extract them as structural features, syntactic features, and textual features. Then, by applying machine learning techniques and noise‐handling techniques, we achieve a precision of 88.5% on eight open‐source software from GitHub. The encouraging experimental results demonstrate the feasibility and effectiveness of our approach.