Multi-Criteria Code Refactoring Using Search-Based Software Engineering

One of the most widely used techniques to improve the quality of existing software systems is refactoring—the process of improving the design of existing code by changing its internal structure without altering its external behavior. While it is important to suggest refactorings that improve the quality and structure of the system, many other criteria are also important to consider, such as reducing the number of code changes, preserving the semantics of the software design and not only its behavior, and maintaining consistency with the previously applied refactorings. In this article, we propose a multi-objective search-based approach for automating the recommendation of refactorings. The process aims at finding the optimal sequence of refactorings that (i) improves the quality by minimizing the number of design defects, (ii) minimizes code changes required to fix those defects, (iii) preserves design semantics, and (iv) maximizes the consistency with the previously code changes. We evaluated the efficiency of our approach using a benchmark of six open-source systems, 11 different types of refactorings (move method, move field, pull up method, pull up field, push down method, push down field, inline class, move class, extract class, extract method, and extract interface) and six commonly occurring design defect types (blob, spaghetti code, functional decomposition, data class, shotgun surgery, and feature envy) through an empirical study conducted with experts. In addition, we performed an industrial validation of our technique, with 10 software engineers, on a large project provided by our industrial partner. We found that the proposed refactorings succeed in preserving the design coherence of the code, with an acceptable level of code change score while reusing knowledge from recorded refactorings applied in the past to similar contexts.

[1]  Laurie J. Hendren,et al.  Optimizing Java Bytecode Using the Soot Framework: Is It Feasible? , 2000, CC.

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

[3]  Miryung Kim,et al.  RefDistiller: a refactoring aware code review tool for inspecting manual refactoring edits , 2014, SIGSOFT FSE.

[4]  Jehad Al Dallal Identifying refactoring opportunities in object-oriented code: A systematic literature review , 2015, Inf. Softw. Technol..

[5]  Johannes Stammel,et al.  Search-based determination of refactorings for improving the class structure of object-oriented systems , 2006, GECCO.

[6]  Ioannis Stamelos,et al.  An empirical investigation of an object-oriented design heuristic for maintainability , 2003, J. Syst. Softw..

[7]  Houari A. Sahraoui,et al.  Can metrics help to bridge the gap between the improvement of OO design quality and its automation? , 2000, Proceedings 2000 International Conference on Software Maintenance.

[8]  Raed Shatnawi,et al.  An empirical study of the bad smells and class error probability in the post-release object-oriented system evolution , 2007, J. Syst. Softw..

[9]  Yuanyuan Zhang,et al.  Search-based software engineering: Trends, techniques and applications , 2012, CSUR.

[10]  Mark Harman,et al.  Search-based amorphous slicing , 2005, 12th Working Conference on Reverse Engineering (WCRE'05).

[11]  Radu Marinescu,et al.  Detection strategies: metrics-based rules for detecting design flaws , 2004, 20th IEEE International Conference on Software Maintenance, 2004. Proceedings..

[12]  Miryung Kim,et al.  Template-based reconstruction of complex refactorings , 2010, 2010 IEEE International Conference on Software Maintenance.

[13]  Gabriele Bavota,et al.  Methodbook: Recommending Move Method Refactorings via Relational Topic Models , 2014, IEEE Transactions on Software Engineering.

[14]  Deepak Goyal,et al.  A hierarchical model for object-oriented design quality assessment , 2015 .

[15]  Colin G. Johnson,et al.  Refactoring in Automatically Generated Programs , 2010 .

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

[17]  Gabriele Bavota,et al.  Recommending refactorings based on team co-maintenance patterns , 2014, ASE.

[18]  Thomas Baar,et al.  A Graphical Approach to Prove the Semantic Preservation of UML/OCL Refactoring Rules , 2006, Ershov Memorial Conference.

[19]  Gabriele Bavota,et al.  Playing with refactoring: Identifying extract class opportunities through game theory , 2010, 2010 IEEE International Conference on Software Maintenance.

[20]  J. R. Landis,et al.  The measurement of observer agreement for categorical data. , 1977, Biometrics.

[21]  Miryung Kim,et al.  An Empirical Study of RefactoringChallenges and Benefits at Microsoft , 2014, IEEE Transactions on Software Engineering.

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

[23]  Mohamed Salah Hamdi SOMSE: A semantic map based meta-search engine for the purpose of web information customization , 2011, Appl. Soft Comput..

[24]  Giovanni Denaro,et al.  ACM Transactions on Software Engineering and Methodology : Volume 22, Nomor 4, 2013 , 2014 .

[25]  Raed Shatnawi,et al.  An Empirical Assessment of Refactoring Impact on Software Quality Using a Hierarchical Quality Model , 2011 .

[26]  L. Erlikh,et al.  Leveraging legacy system dollars for e-business , 2000 .

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

[28]  Houari A. Sahraoui,et al.  Search-based refactoring: Towards semantics preservation , 2012, 2012 28th IEEE International Conference on Software Maintenance (ICSM).

[29]  Mika Mäntylä,et al.  A taxonomy and an initial empirical study of bad smells in code , 2003, International Conference on Software Maintenance, 2003. ICSM 2003. Proceedings..

[30]  Houari A. Sahraoui,et al.  Search-Based Refactoring Using Recorded Code Changes , 2013, 2013 17th European Conference on Software Maintenance and Reengineering.

[31]  Aiko Fallas Yamashita,et al.  Do developers care about code smells? An exploratory survey , 2013, 2013 20th Working Conference on Reverse Engineering (WCRE).

[32]  Mark Harman,et al.  Experimental assessment of software metrics using automated refactoring , 2012, Proceedings of the 2012 ACM-IEEE International Symposium on Empirical Software Engineering and Measurement.

[33]  Nikolaos Tsantalis,et al.  Unification and refactoring of clones , 2014, 2014 Software Evolution Week - IEEE Conference on Software Maintenance, Reengineering, and Reverse Engineering (CSMR-WCRE).

[34]  Adnan Shaout,et al.  Many-Objective Software Remodularization Using NSGA-III , 2015, TSEM.

[35]  Shari Lawrence Pfleeger,et al.  Software metrics (2nd ed.): a rigorous and practical approach , 1997 .

[36]  Andrew P. Black,et al.  Programmer-Friendly Refactoring Errors , 2012, IEEE Transactions on Software Engineering.

[37]  Shari Lawrence Pfleeger,et al.  Software Metrics : A Rigorous and Practical Approach , 1998 .

[38]  Raquel Amaro,et al.  Enriching Wordnets with New Relations and with Event and Argument Structures , 2006, CICLing.

[39]  Yann-Gaël Guéhéneuc,et al.  Refactorings of Design Defects Using Relational Concept Analysis , 2008, ICFCA.

[40]  Houari A. Sahraoui,et al.  Design Defects Detection and Correction by Example , 2011, 2011 IEEE 19th International Conference on Program Comprehension.

[41]  Jens Palsberg,et al.  Scalable propagation-based call graph construction algorithms , 2000, OOPSLA '00.

[42]  Houari A. Sahraoui,et al.  Maintainability defects detection and correction: a multi-objective approach , 2013, Automated Software Engineering.

[43]  Lothar Thiele,et al.  Multiobjective Optimization Using Evolutionary Algorithms - A Comparative Case Study , 1998, PPSN.

[44]  Andrew P. Black,et al.  An interactive ambient visualization for code smells , 2010, SOFTVIS '10.

[45]  Nicolas Anquetil,et al.  Legacy Software Restructuring: Analyzing a Concrete Case , 2011, 2011 15th European Conference on Software Maintenance and Reengineering.

[46]  Ricardo Terra,et al.  Recommending Move Method refactorings using dependency sets , 2013, 2013 20th Working Conference on Reverse Engineering (WCRE).

[47]  Gustavo Soares Soares Automated behavioral testing of refactoring engines , 2012, SPLASH '12.

[48]  Gabriele Bavota,et al.  Recommending Refactoring Operations in Large Software Systems , 2014, Recommendation Systems in Software Engineering.

[49]  Agostino Cortesi,et al.  Semantic Hierarchy Refactoring by Abstract Interpretation , 2006, VMCAI.

[50]  Yann-Gaël Guéhéneuc,et al.  DECOR: A Method for the Specification and Detection of Code and Design Smells , 2010, IEEE Transactions on Software Engineering.

[51]  C. Fonseca,et al.  GENETIC ALGORITHMS FOR MULTI-OBJECTIVE OPTIMIZATION: FORMULATION, DISCUSSION, AND GENERALIZATION , 1993 .

[52]  Eleni Stroulia,et al.  JDeodorant: identification and application of extract class refactorings , 2011, 2011 33rd International Conference on Software Engineering (ICSE).

[53]  Reiko Heckel,et al.  Local Search-Based Refactoring as Graph Transformation , 2009, 2009 1st International Symposium on Search Based Software Engineering.

[54]  P. Jaccard,et al.  Etude comparative de la distribution florale dans une portion des Alpes et des Jura , 1901 .

[55]  Emerson R. Murphy-Hill,et al.  Manual refactoring changes with automated refactoring validation , 2014, ICSE.

[56]  KessentiniMarouane,et al.  Multi-Criteria Code Refactoring Using Search-Based Software Engineering , 2016 .

[57]  N. Cliff Dominance statistics: Ordinal analyses to answer ordinal questions. , 1993 .

[58]  Mark Kent O'Keeffe,et al.  Search-based refactoring for software maintenance , 2008, J. Syst. Softw..

[59]  William F. Opdyke,et al.  Refactoring object-oriented frameworks , 1992 .

[60]  Mark Harman,et al.  Evolving transformation sequences using genetic algorithms , 2004 .

[61]  Alberto Bacchelli,et al.  On the Impact of Design Flaws on Software Defects , 2010, 2010 10th International Conference on Quality Software.

[62]  Chanchal Kumar Roy,et al.  A Constraint Programming Approach to Conflict-Aware Optimal Scheduling of Prioritized Code Clone Refactoring , 2011, 2011 IEEE 11th International Working Conference on Source Code Analysis and Manipulation.

[63]  Jan Verelst,et al.  Refactoring - improving coupling and cohesion of existing code , 2004, 11th Working Conference on Reverse Engineering.

[64]  Betty H. C. Cheng,et al.  On the use of genetic programming for automated refactoring and the introduction of design patterns , 2010, GECCO '10.

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

[66]  E. Murphy-Hill,et al.  Breaking the barriers to successful refactoring , 2008, 2008 ACM/IEEE 30th International Conference on Software Engineering.

[67]  Andrew P. Black,et al.  Breaking the barriers to successful refactoring: observations and tools for extract method , 2008, ICSE.

[68]  Danny Dig,et al.  LambdaFicator: From imperative to functional programming through automated refactoring , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[69]  Hürevren Kiliç,et al.  Search-Based Parallel Refactoring Using Population-Based Direct Approaches , 2011, SSBSE.

[70]  Ladan Tahvildari,et al.  A metric-based approach to enhance design quality through meta-pattern transformations , 2003, Seventh European Conference onSoftware Maintenance and Reengineering, 2003. Proceedings..

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

[72]  Sergio Di Martino,et al.  LINSEN: An efficient approach to split identifiers and expand abbreviations , 2012, 2012 28th IEEE International Conference on Software Maintenance (ICSM).

[73]  Jacob Cohen A Coefficient of Agreement for Nominal Scales , 1960 .

[74]  Gabriele Bavota,et al.  Supporting extract class refactoring in Eclipse: The ARIES project , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[75]  Mark Harman,et al.  Pareto optimal search based refactoring at the design level , 2007, GECCO '07.

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

[77]  Mel O Cinn eide Automated application of design patterns: a refactoring approach , 2001 .

[78]  Giuseppe Scanniello,et al.  Investigating the use of lexical information for software system clustering , 2011, 2011 15th European Conference on Software Maintenance and Reengineering.

[79]  Pierre Poulin,et al.  Visual Detection of Design Anomalies , 2008, 2008 12th European Conference on Software Maintenance and Reengineering.

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

[81]  Don Roberts,et al.  Practical analysis for refactoring , 1999 .

[82]  William G. Griswold,et al.  Automated support for program refactoring using invariants , 2001, Proceedings IEEE International Conference on Software Maintenance. ICSM 2001.

[83]  Houari A. Sahraoui,et al.  Deviance from perfection is a better criterion than closeness to evil when identifying risky code , 2010, ASE.

[84]  Thomas J. Mowbray,et al.  AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis , 1998 .

[85]  Andrew P. Black,et al.  How We Refactor, and How We Know It , 2012, IEEE Trans. Software Eng..

[86]  Stas Negara,et al.  A Comparative Study of Manual and Automated Refactorings , 2013, ECOOP.

[87]  R. Likert “Technique for the Measurement of Attitudes, A” , 2022, The SAGE Encyclopedia of Research Design.

[88]  Kalyanmoy Deb,et al.  A fast and elitist multiobjective genetic algorithm: NSGA-II , 2002, IEEE Trans. Evol. Comput..

[89]  Giuseppe Scanniello,et al.  Using the Kleinberg Algorithm and Vector Space Model for Software System Clustering , 2010, 2010 IEEE 18th International Conference on Program Comprehension.

[90]  Peter J. Fleming,et al.  Genetic Algorithms for Multiobjective Optimization: FormulationDiscussion and Generalization , 1993, ICGA.

[91]  Gabriele Bavota,et al.  Improving software modularization via automated analysis of latent topics and dependencies , 2014, TSEM.

[92]  Houari A. Sahraoui,et al.  The use of development history in software refactoring using a multi-objective evolutionary algorithm , 2013, GECCO '13.

[93]  Rushikesh K. Joshi,et al.  Concept Analysis for Class Cohesion , 2009, 2009 13th European Conference on Software Maintenance and Reengineering.