Learning a Metric for Code Readability

被引:236
作者
Buse, Raymond P. L. [1 ]
Weimer, Westley R. [1 ]
机构
[1] Univ Virginia, Charlottesville, VA 22904 USA
关键词
Software readability; program understanding; machine learning; software maintenance; code metrics; FindBugs; PROGRAM READABILITY; SOFTWARE;
D O I
10.1109/TSE.2009.70
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
In this paper, we explore the concept of code readability and investigate its relation to software quality. With data collected from 120 human annotators, we derive associations between a simple set of local code features and human notions of readability. Using those features, we construct an automated readability measure and show that it can be 80 percent effective and better than a human, on average, at predicting readability judgments. Furthermore, we show that this metric correlates strongly with three measures of software quality: code changes, automated defect reports, and defect log messages. We measure these correlations on over 2.2 million lines of code, as well as longitudinally, over many releases of selected projects. Finally, we discuss the implications of this study on programming language design and engineering practice. For example, our data suggest that comments, in and of themselves, are less important than simple blank lines to local judgments of readability.
引用
收藏
页码:546 / 558
页数:13
相关论文
共 41 条
[31]  
Raymond DarrellR., 1991, P 1991 C CTR ADV STU, P3
[32]  
Relf P.A., 2005, P INT S EMP SOFTW EN
[33]   The use of domain knowledge in program understanding [J].
Rugaber, S .
ANNALS OF SOFTWARE ENGINEERING, 2000, 9 (1-4) :143-192
[34]  
SIMONYI C, 1999, MSDN LIB NOV
[35]   DERIVATION AND VALIDATION OF AUTOMATED READABILITY INDEX FOR USE WITH TECHNICAL MATERIALS [J].
SMITH, EA ;
KINCAID, JP .
HUMAN FACTORS, 1970, 12 (05) :457-&
[36]  
Stemler S.E., 2004, A comparison of consensus, consistency, and measurement approaches
[37]  
Sutter Herb, 2004, C++ coding standards: 101 rules, guidelines, and best practices
[38]   PROGRAM READABILITY - PROCEDURES VERSUS COMMENTS [J].
TENNY, T .
IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, 1988, 14 (09) :1271-1279
[39]  
Watters A., 1996, INTERNET PROGRAMMING
[40]   EVALUATING SOFTWARE COMPLEXITY-MEASURES [J].
WEYUKER, EJ .
IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, 1988, 14 (09) :1357-1365