A Context-based Automated Approach for Method Name Consistency Checking and Suggestion
Yi Li, Shaohua Wang, Tien N. Nguyen
Abstract
Misleading method names in software projects can confuse developers, which may lead to software defects and affect code understandability. In this paper, we present DeepName, a context-based, deep learning approach to detect method name inconsistencies and suggest a proper name for a method. The key departure point is the philosophy of "Show Me Your Friends, I'll Tell You Who You Are". Unlike the state-of-the-art approaches, in addition to the method's body, we also consider the interactions of the current method under study with the other ones including the caller and callee methods, and the sibling methods in the same enclosing class. The sequences of sub-tokens in the program entities' names in the contexts are extracted and used as the input for an RNN-based encoder-decoder to produce the representations for the current method. We modify that RNN model to integrate the copy mechanism and our newly developed component, called the non-copy mechanism, to emphasize on the possibility of a certain sub-token not to be copied to follow the current sub-token in the currently generated method name. We conducted several experiments to evaluate DeepName on large datasets with +14M methods. For consistency checking, DeepName improves the state-of-the-art approach by 2.1%, 19.6%, and 11.9% relatively in recall, precision, and F-score, respectively. For name suggestion, DeepName improves relatively over the state-of-the-art approaches in precision (1.8%-30.5%), recall (8.8%-46.1%), and F-score (5.2%-38.2%). To assess DeepName's usefulness, we detected inconsistent methods and suggested new method names in active projects. Among 50 pull requests, 12 were merged into the main branch. In total, in 30/50 cases, the team members agree that our suggested method names are more meaningful than the current names.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 4d8bfed0-69b0-4574-9ee3-6d2aa68999d1Cited by top-tier papers9
- SymLM: Predicting Function Names in Stripped Binaries via Context-Sensitive Execution-Aware Code EmbeddingsXin Jin, Kexin Pei, Jun Yeon Won, Zhiqiang LinCCS 2022 · 56 citations
- Lightweight global and local contexts guided method name recommendation with prior knowledgeShangwen Wang, Ming Wen, Bo Lin, Xiaoguang MaoFSE 2021 · 38 citations
- Learning to Recommend Method Names with Global ContextFang Liu, Ge Li, Zhiyi Fu, Shuai Lu et al.ICSE 2022 · 32 citations
- Two Sides of the Same Coin: Exploiting the Impact of Identifiers in Neural Code ComprehensionShuzheng Gao, Cuiyun Gao, Chaozheng Wang, Jun Sun et al.ICSE 2023 · 17 citations
- Natural Is the Best: Model-Agnostic Code Simplification for Pre-trained Large Language ModelsYan Wang, Xiaoning Li, Tien N. Nguyen, Shaohua Wang et al.FSE 2024 · 6 citations
Builds on2
Related papers
- LLM-Based Method Name Suggestion with Automatically Generated Context-Rich PromptsWaseem Akram, Yanjie Jiang, Yuxia Zhang, Haris Ali Khan et al.FSE 2025 · 1 citation
- DeepTC-Enhancer: Improving the Readability of Automatically Generated TestsDevjeet Roy, Ziyi Zhang, Maggie Ma, Venera Arnaoudova et al.ASE 2020 · 32 citations
- Learning to find naming issues with big code and small supervisionJingxuan He, Cheng-Chun Lee, Veselin Raychev, Martin T. VechevPLDI 2021 · 9 citations
- Nalin: learning from Runtime Behavior to Find Name-Value Inconsistencies in Jupyter NotebooksJibesh Patra, Michael PradelICSE 2022 · 14 citations
- Deep Just-In-Time Inconsistency Detection Between Comments and Source CodeSheena Panthaplackel, Junyi Jessy Li, Milos Gligoric, Raymond J. MooneyAAAI 2021 · 62 citations
