Suggesting Natural Method Names to Check Name Consistencies
Misleading names of the methods in a project or the APIs in a software library confuse developers about program functionality and API usages, leading to API misuses and defects. In this paper, we introduce MNIRE, a machine learning approach to check the consistency between the name of a given method and its implementation. MNIRE first generates a candidate name and compares the current name against it. If the two names are sufficiently similar, we consider the method as consistent. To generate the method name, we draw our ideas and intuition from an empirical study on the nature of method names in a large dataset. Our key findings are that high proportions of the tokens of method names can be found in the three contexts of a given method including its body, the interface (the method’s parameter types and return type), and the enclosing class’ name. Even when such tokens are not there, MNIRE uses the contexts to predict the tokens due to the high co-occurrence likelihoods. Our unique idea is to treat the name generation as an abstract summarization on the tokens collected from the names of the program entities in the three above contexts.
We conducted several experiments to evaluate MNIRE in method name consistency checking and in method name recommending on large datasets with +14M methods. In detecting inconsistency method names, MNIRE improves the state-of-the-art approach by 10.4% and 11% relatively in recall and precision, respectively. In method name recommendation, MNIRE improves relatively over the state-of-the-art technique, code2vec, in both recall (18.2% higher) and precision (11.1% higher). To assess MNIRE’s usefulness, we used it to detect inconsistent methods and suggest new names in several active, GitHub projects. We made 50 pull requests and received 42 responses. Among them, 5 PRs were merged into the main branch, and 13 were approved for later merging. In total, in 31/42 cases, the developer teams agree that our suggested names are more meaningful than the current names, showing MNIRE’s usefulness.
Wed 7 Oct
|14:00 - 14:20|
|14:20 - 14:40|
CPC: Automatically Classifying and Propagating Natural Language Comments via Program AnalysisTechnical
Juan ZhaiRutgers University, Xiangzhe XuNanjing University, Yu ShiPurdue University, Guanhong TaoPurdue University, Minxue PanNanjing University, Shiqing MaRutgers University, Lei XuNational Key Laboratory for Novel Software Technology, Nanjing University, Weifeng ZhangNanjing University of Posts and Telecommunications, Lin TanPurdue University, Xiangyu ZhangPurdue University
|14:40 - 15:00|
|15:00 - 15:20|
Jian ZhangBeihang University, Xu WangBeihang University, Hongyu ZhangThe University of Newcastle, Hailong SunBeihang University, Xudong LiuBeihang UniversityPre-print
|15:20 - 15:30|
|15:30 - 15:40|