Suggesting Natural Method Names to Check Name ConsistenciesTechnical
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.
Tue 7 JulDisplayed time zone: (UTC) Coordinated Universal Time change
15:00 - 16:00 | A3-Code SummarizationTechnical Papers / New Ideas and Emerging Results at Silla Chair(s): Shaohua Wang New Jersey Institute of Technology, USA | ||
15:00 12mTalk | Posit: Simultaneously Tagging Natural and Programming LanguagesTechnical Technical Papers Profir-Petru Pârțachi University College London, Santanu Dash University College London, UK, Christoph Treude The University of Adelaide, Earl T. Barr University College London, UK Pre-print Media Attached File Attached | ||
15:12 12mTalk | CPC: Automatically Classifying and Propagating Natural Language Comments via Program AnalysisTechnical Technical Papers Juan Zhai Rutgers University, Xiangzhe Xu Nanjing University, Yu Shi Purdue University, Guanhong Tao Purdue University, Minxue Pan Nanjing University, Shiqing Ma Rutgers University, Lei Xu National Key Laboratory for Novel Software Technology, Nanjing University, Weifeng Zhang Nanjing University of Posts and Telecommunications, Lin Tan Purdue University, Xiangyu Zhang Purdue University | ||
15:24 12mTalk | Suggesting Natural Method Names to Check Name ConsistenciesTechnical Technical Papers Son Nguyen The University of Texas at Dallas, Hung Phan , Trinh Le University of Engineering and Technology, Tien N. Nguyen University of Texas at Dallas Pre-print | ||
15:36 6mTalk | Where should I comment my code? A dataset and model for predicting locations that need commentsNIER New Ideas and Emerging Results Annie Louis University of Edinburgh, Santanu Dash University College London, UK, Earl T. Barr University College London, UK, Michael D. Ernst University of Washington, USA, Charles Sutton Google Research | ||
15:42 12mTalk | Retrieval-based Neural Source Code SummarizationTechnical Technical Papers Jian Zhang Beihang University, Xu Wang Beihang University, Hongyu Zhang University of Newcastle, Australia, Hailong Sun Beihang University, Xudong Liu Beihang University Pre-print | ||
15:54 6mTalk | The Dual Channel HypothesisNIER New Ideas and Emerging Results Casey Casalnuovo University of California at Davis, USA, Earl T. Barr University College London, UK, Santanu Dash University College London, UK, Prem Devanbu University of California, Emily Morgan University of California, Davis |