A Context-based Automated Approach for Method Name Consistency Checking and Suggestion

02/27/2021
by   Yi Li, et al.
0

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 F-score, respectively. For name suggestion, DeepName improves relatively over the state-of-the-art approaches in precision (1.8 (8.8 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.

READ FULL TEXT
POST COMMENT

Comments

There are no comments yet.

Authors

page 2

page 3

page 6

page 8

page 9

page 10

page 11

page 12

03/20/2021

Keywords Guided Method Name Generation

High quality method names are descriptive and readable, which are helpfu...
08/31/2018

Context2Name: A Deep Learning-Based Approach to Infer Natural Variable Names from Usage Contexts

Most of the JavaScript code deployed in the wild has been minified, a pr...
04/16/2020

Deep Generation of Coq Lemma Names Using Elaborated Terms

Coding conventions for naming, spacing, and other essentially stylistic ...
02/25/2019

Neural Reverse Engineering of Stripped Binaries

We address the problem of predicting procedure names in stripped executa...
07/12/2019

Mercem: Method Name Recommendation Based on Call Graph Embedding

Comprehensibility of source code is strongly affected by identifier name...
02/13/2018

Substation Signal Matching with a Bagged Token Classifier

Currently, engineers at substation service providers match customer data...
02/11/2018

Tree-to-tree Neural Networks for Program Translation

Program translation is an important tool to migrate legacy code in one l...
This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.