Recommending Extract Method Refactoring Based on Confidence of Predicted Method Name

Refactoring is an important activity that is frequently performed in software development, and among them, Extract Method is known to be one of the most frequently performed refactorings. The existing techniques for recommending Extract Method refactoring calculate metrics from the source method and the code fragments to be extracted to order the recommendation candidates. This paper proposes a new technique for accurately recommending Extract Method refactoring by considering whether code fragments are semantically coherent chunks that can be given clear method names, in addition to the metrics used in previous studies. As a criterion for the semantic coherency, the proposed technique employs the probability (i.e. confidence) of the predicted method names for the code fragments output by code2seq, which is a state-of-the-art method name prediction technique. The evaluation experiment confirmed that the proposed technique has higher correctness of recommendation than the existing techniques.

[1]  Tom Mens,et al.  A survey of software refactoring , 2004, IEEE Transactions on Software Engineering.

[2]  Takuya Akiba,et al.  Optuna: A Next-generation Hyperparameter Optimization Framework , 2019, KDD.

[3]  Uri Alon,et al.  code2vec: learning distributed representations of code , 2018, Proc. ACM Program. Lang..

[4]  Einar W. Høst,et al.  Debugging Method Names , 2009, ECOOP.

[5]  Apostolos Ampatzoglou,et al.  Identifying Extract Method Refactoring Opportunities Based on Functional Relevance , 2017, IEEE Transactions on Software Engineering.

[6]  Omer Levy,et al.  code2seq: Generating Sequences from Structured Representations of Code , 2018, ICLR.

[7]  Gabriele Bavota,et al.  Identifying Extract Class refactoring opportunities using structural and semantic cohesion measures , 2011, J. Syst. Softw..

[8]  Jing Xu,et al.  GEMS: An Extract Method Refactoring Recommender , 2017, 2017 IEEE 28th International Symposium on Software Reliability Engineering (ISSRE).

[9]  Alexander Chatzigeorgiou,et al.  Identification of refactoring opportunities introducing polymorphism , 2010, J. Syst. Softw..

[10]  Alexander Chatzigeorgiou,et al.  Investigating the Evolution of Bad Smells in Object-Oriented Code , 2010, 2010 Seventh International Conference on the Quality of Information and Communications Technology.

[11]  Andrea De Lucia,et al.  Comparing Heuristic and Machine Learning Approaches for Metric-Based Code Smell Detection , 2019, 2019 IEEE/ACM 27th International Conference on Program Comprehension (ICPC).

[12]  Ricardo Terra,et al.  JExtract: An Eclipse Plug-in for Recommending Automated Extract Method Refactorings , 2015, ArXiv.

[13]  Gaël Varoquaux,et al.  Scikit-learn: Machine Learning in Python , 2011, J. Mach. Learn. Res..

[14]  Marc Brockschmidt,et al.  Learning to Represent Programs with Graphs , 2017, ICLR.

[15]  Ricardo Terra,et al.  Recommending automated extract method refactorings , 2014, ICPC 2014.

[16]  Marco Tulio Valente,et al.  Why we refactor? confessions of GitHub contributors , 2016, SIGSOFT FSE.

[17]  Alexander Chatzigeorgiou,et al.  Identification of Move Method Refactoring Opportunities , 2009, IEEE Transactions on Software Engineering.

[18]  Mohammad Alshayeb,et al.  Automatic software refactoring: a systematic literature review , 2019, Software Quality Journal.

[19]  Einar W. Høst,et al.  The Programmer's Lexicon, Volume I: The Verbs , 2007, Seventh IEEE International Working Conference on Source Code Analysis and Manipulation (SCAM 2007).

[20]  Yaroslav Golubev,et al.  Recommendation of Move Method Refactoring Using Path-Based Representation of Code , 2020, ICSE.

[21]  Alexander Chatzigeorgiou,et al.  Identification of extract method refactoring opportunities for the decomposition of methods , 2011, J. Syst. Softw..

[22]  Gabriele Bavota,et al.  Automating extract class refactoring: an improved method and its evaluation , 2013, Empirical Software Engineering.

[23]  Wei-Yin Loh,et al.  Classification and regression trees , 2011, WIREs Data Mining Knowl. Discov..

[24]  Ricardo Terra,et al.  JMove: A novel heuristic and tool to detect move method refactoring opportunities , 2018, J. Syst. Softw..

[25]  Mauricio A. Saca Refactoring improving the design of existing code , 2017, 2017 IEEE 37th Central America and Panama Convention (CONCAPAN XXXVII).

[26]  Charles A. Sutton,et al.  A Convolutional Attention Network for Extreme Summarization of Source Code , 2016, ICML.

[27]  Eleni Stroulia,et al.  Identification and application of Extract Class refactorings in object-oriented systems , 2012, J. Syst. Softw..

[28]  Davood Mazinanian,et al.  Clone Refactoring with Lambda Expressions , 2017, 2017 IEEE/ACM 39th International Conference on Software Engineering (ICSE).

[29]  C MurphyGail,et al.  How Are Java Software Developers Using the Eclipse IDE , 2006 .

[30]  Katsuro Inoue,et al.  Recommending verbs for rename method using association rule mining , 2014, 2014 Software Evolution Week - IEEE Conference on Software Maintenance, Reengineering, and Reverse Engineering (CSMR-WCRE).