MORE: A multi‐objective refactoring recommendation approach to introducing design patterns and fixing code smells

Refactoring is widely recognized as a crucial technique applied when evolving object‐oriented software systems. If applied well, refactoring can improve different aspects of software quality including readability, maintainability, and extendibility. However, despite its importance and benefits, recent studies report that automated refactoring tools are underused much of the time by software developers. This paper introduces an automated approach for refactoring recommendation, called MORE, driven by 3 objectives: (1) to improve design quality (as defined by software quality metrics), (2) to fix code smells, and (3) to introduce design patterns. To this end, we adopt the recent nondominated sorting genetic algorithm, NSGA‐III, to find the best trade‐off between these 3 objectives. We evaluated the efficacy of our approach using a benchmark of 7 medium and large open‐source systems, 7 commonly occurring code smells (god class, feature envy, data class, spaghetti code, shotgun surgery, lazy class, and long parameter list), and 4 common design pattern types (visitor, factory method, singleton, and strategy). Our approach is empirically evaluated through a quantitative and qualitative study to compare it against 3 different state‐of‐the art approaches, 2 popular multiobjective search algorithms, and random search. The statistical analysis of the results confirms the efficacy of our approach in improving the quality of the studied systems while successfully fixing 84% of code smells and introducing an average of 6 design patterns. In addition, the qualitative evaluation shows that most of the suggested refactorings (an average of 69%) are considered by developers to be relevant and meaningful.

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

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

[3]  Serge Demeyer,et al.  Studying the Effect of Refactorings: A Complexity Metrics Perspective , 2010, 2010 Seventh International Conference on the Quality of Information and Communications Technology.

[4]  Jeremy Singer,et al.  Search-Based Refactoring: Metrics Are Not Enough , 2015, SSBSE 2015.

[5]  Miryung Kim,et al.  A field study of refactoring challenges and benefits , 2012, SIGSOFT FSE.

[6]  Dean C. Karnopp,et al.  Random search techniques for optimization problems , 1963, at - Automatisierungstechnik.

[7]  Houari A. Sahraoui,et al.  A Cooperative Parallel Search-Based Software Engineering Approach for Code-Smells Detection , 2014, IEEE Transactions on Software Engineering.

[8]  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.

[9]  Mark Harman,et al.  The Current State and Future of Search Based Software Engineering , 2007, Future of Software Engineering (FOSE '07).

[10]  S. H. Kannangara,et al.  An Empirical Evaluation of Impact of Refactoring On Internal and External Measures of Code Quality , 2015, ArXiv.

[11]  Akram Ajouli,et al.  Vues et transformations de programmes pour la modularité des évolutions. (Views and program transformations for modular maintenances) , 2013 .

[12]  John E. Dennis,et al.  Normal-Boundary Intersection: A New Method for Generating the Pareto Surface in Nonlinear Multicriteria Optimization Problems , 1998, SIAM J. Optim..

[13]  Welf Löwe,et al.  Automatic design pattern detection , 2003, 11th IEEE International Workshop on Program Comprehension, 2003..

[14]  Friedrich Steimann,et al.  A Refactoring Constraint Language and Its Application to Eiffel , 2011, ECOOP.

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

[16]  David Grove,et al.  Optimization of Object-Oriented Programs Using Static Class Hierarchy Analysis , 1995, ECOOP.

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

[18]  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..

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

[20]  Don S. Batory,et al.  Scripting parametric refactorings in Java to retrofit design patterns , 2015, 2015 IEEE International Conference on Software Maintenance and Evolution (ICSME).

[21]  Mel Ó Cinnéide,et al.  A methodology for the automated introduction of design patterns , 1999, Proceedings IEEE International Conference on Software Maintenance - 1999 (ICSM'99). 'Software Maintenance for Business Change' (Cat. No.99CB36360).

[22]  Kalyanmoy Deb,et al.  Controlled Elitist Non-dominated Sorting Genetic Algorithms for Better Convergence , 2001, EMO.

[23]  Mel Ó Cinnéide,et al.  A stochastic approach to automated design improvement , 2003, PPPJ.

[24]  Peter M. Chisnall,et al.  Questionnaire Design, Interviewing and Attitude Measurement , 1993 .

[25]  Mark Harman,et al.  Evolving transformation sequences using genetic algorithms , 2004, Source Code Analysis and Manipulation, Fourth IEEE International Workshop on.

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

[27]  Carl G. Davis,et al.  A Hierarchical Model for Object-Oriented Design Quality Assessment , 2002, IEEE Trans. Software Eng..

[28]  Janez Demsar,et al.  Statistical Comparisons of Classifiers over Multiple Data Sets , 2006, J. Mach. Learn. Res..

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

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

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

[32]  Ralph Johnson,et al.  Design patterns: elements of reuseable object-oriented software , 1994 .

[33]  Amnon H. Eden,et al.  Precise specification and automatic application of design patterns , 1997, Proceedings 12th IEEE International Conference Automated Software Engineering.

[34]  Meir M. Lehman,et al.  Program evolution: processes of software change , 1985 .

[35]  Jacob Cohen Statistical Power Analysis for the Behavioral Sciences , 1969, The SAGE Encyclopedia of Research Design.

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

[37]  Kalyanmoy Deb,et al.  An Evolutionary Many-Objective Optimization Algorithm Using Reference-Point-Based Nondominated Sorting Approach, Part I: Solving Problems With Box Constraints , 2014, IEEE Transactions on Evolutionary Computation.

[38]  Lionel C. Briand,et al.  A practical guide for using statistical tests to assess randomized algorithms in software engineering , 2011, 2011 33rd International Conference on Software Engineering (ICSE).

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

[40]  Robert M. Hierons,et al.  Exploring the Eradication of Code Smells: An Empirical and Theoretical Perspective , 2010, Adv. Softw. Eng..

[41]  Cornelis Pronk,et al.  On the Interaction between Metrics and Patterns , 1995, OOIS.

[42]  Katsuro Inoue,et al.  Improving multi-objective code-smells correction using development history , 2015, J. Syst. Softw..

[43]  Marouane Kessentini,et al.  Search-Based Web Service Antipatterns Detection , 2017, IEEE Transactions on Services Computing.

[44]  Katsuro Inoue,et al.  Web Service Antipatterns Detection Using Genetic Programming , 2015, GECCO.

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

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

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

[48]  Günther Ruhe,et al.  Search Based Software Engineering , 2013, Lecture Notes in Computer Science.

[49]  Marouane Kessentini,et al.  Bi-level Identification of Web Service Defects , 2016, ICSOC.

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

[51]  Diomidis Spinellis,et al.  Refactoring--Does It Improve Software Quality? , 2007, Fifth International Workshop on Software Quality (WoSQ'07: ICSE Workshops 2007).

[52]  Joshua Kerievsky,et al.  Refactoring to Patterns , 2004, XP/Agile Universe.

[53]  Martin Fowler,et al.  Refactoring - Improving the Design of Existing Code , 1999, Addison Wesley object technology series.

[54]  Martin Fowler. Refactoring Improving the Design of Existing Code , 1999 .

[55]  Katsuro Inoue,et al.  SIM: An Automated Approach to Improve Web Service Interface Modularization , 2016, 2016 IEEE International Conference on Web Services (ICWS).

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

[57]  Qingfu Zhang,et al.  Multiobjective Optimization Problems With Complicated Pareto Sets, MOEA/D and NSGA-II , 2009, IEEE Transactions on Evolutionary Computation.

[58]  Alexander Chatzigeorgiou,et al.  JDeodorant: Identification and Removal of Feature Envy Bad Smells , 2007, ICSM.

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

[60]  David F. Bacon,et al.  Fast static analysis of C++ virtual function calls , 1996, OOPSLA '96.

[61]  Maninder Singh,et al.  Software clone detection: A systematic review , 2013, Inf. Softw. Technol..

[62]  Rudolf Ferenc,et al.  Using the Conceptual Cohesion of Classes for Fault Prediction in Object-Oriented Systems , 2008, IEEE Transactions on Software Engineering.

[63]  Katsuro Inoue,et al.  Multi-Criteria Code Refactoring Using Search-Based Software Engineering , 2016, ACM Trans. Softw. Eng. Methodol..

[64]  Emerson R. Murphy-Hill,et al.  BeneFactor: a flexible refactoring tool for eclipse , 2011, OOPSLA Companion.

[65]  Ondrej Lhoták,et al.  The Soot framework for Java program analysis: a retrospective , 2011 .

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

[67]  Gabriele Bavota,et al.  An empirical study on the developers' perception of software coupling , 2013, 2013 35th International Conference on Software Engineering (ICSE).

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

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

[70]  Gabriele Bavota,et al.  A two-step technique for extract class refactoring , 2010, ASE.

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

[72]  Peter Wendorff Assessment of Design Patterns during Software Reengineering: Lessons Learned from a Large Commercial Project , 2001, CSMR.

[73]  Dong Zhou,et al.  Translation techniques in cross-language information retrieval , 2012, CSUR.

[74]  Hafedh Mili,et al.  Understanding design patterns — what is the problem? , 2012, Softw. Pract. Exp..

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

[76]  A. E. Eiben,et al.  Parameter tuning for configuring and analyzing evolutionary algorithms , 2011, Swarm Evol. Comput..

[77]  Jean-Claude Royer,et al.  Transformations between Composite and Visitor Implementations in Java , 2013, 2013 39th Euromicro Conference on Software Engineering and Advanced Applications.

[78]  Daniela Cruzes,et al.  The evolution and impact of code smells: A case study of two open source systems , 2009, 2009 3rd International Symposium on Empirical Software Engineering and Measurement.

[79]  Tom Mens,et al.  Formalizing refactorings with graph transformations , 2005, J. Softw. Maintenance Res. Pract..

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

[81]  Ivar Jacobson,et al.  Object Design: Roles, Responsibilities, and Collaborations , 2002 .

[82]  Yuanyuan Zhang,et al.  Search Based Software Engineering: A Comprehensive Analysis and Review of Trends Techniques and Applications , 2009 .

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

[84]  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..

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

[86]  E. Murphy-Hill,et al.  Refactoring Tools: Fitness for Purpose , 2006, IEEE Software.

[87]  Oege de Moor,et al.  JunGL: a scripting language for refactoring , 2006, ICSE.

[88]  Carlos A. Coello Coello,et al.  Solving Multiobjective Optimization Problems Using an Artificial Immune System , 2005, Genetic Programming and Evolvable Machines.

[89]  Andrew P. Black,et al.  How we refactor, and how we know it , 2009, 2009 IEEE 31st International Conference on Software Engineering.

[90]  Foutse Khomh,et al.  Do Design Patterns Impact Software Quality Positively? , 2008, 2008 12th European Conference on Software Maintenance and Reengineering.

[91]  Shinichi Nakagawa A farewell to Bonferroni: the problems of low statistical power and publication bias , 2004, Behavioral Ecology.

[92]  Ali Ounia,et al.  A Multi-Objective Refactoring Approach to Introduce Design Patterns and Fix Anti-Patterns , 2015 .

[93]  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.

[94]  Gary B. Lamont,et al.  Multiobjective evolutionary algorithm test suites , 1999, SAC '99.