An Interactive and Dynamic Search-Based Approach to Software Refactoring Recommendations

Successful software products evolve through a process of continual change. However, this process may weaken the design of the software and make it unnecessarily complex, leading to significantly reduced productivity and increased fault-proneness. Refactoring improves the software design while preserving overall functionality and behavior, and is an important technique in managing the growing complexity of software systems. Most of the existing work on software refactoring uses either an entirely manual or a fully automated approach. Manual refactoring is time-consuming, error-prone and unsuitable for large-scale, radical refactoring. On the other hand, fully automated refactoring yields a static list of refactorings which, when applied, leads to a new and often hard to comprehend design. Furthermore, it is difficult to merge these refactorings with other changes performed in parallel by developers. In this paper, we propose a refactoring recommendation approach that dynamically adapts and interactively suggests refactorings to developers and takes their feedback into consideration. Our approach uses NSGA-II to find a set of good refactoring solutions that improve software quality while minimizing the deviation from the initial design. These refactoring solutions are then analyzed to extract interesting common features between them such as the frequently occurring refactorings in the best non-dominated solutions. Based on this analysis, the refactorings are ranked and suggested to the developer in an interactive fashion as a sequence of transformations. The developer can approve, modify or reject each of the recommended refactorings, and this feedback is then used to update the proposed rankings of recommended refactorings. After a number of introduced code changes and interactions with the developer, the interactive NSGA-II algorithm is executed again on the new modified system to repair the set of refactoring solutions based on the new changes and the feedback received from the developer. We evaluated our approach on a set of eight open source systems and two industrial projects provided by an industrial partner. Statistical analysis of our experiments shows that our dynamic interactive refactoring approach performed significantly better than four existing search-based refactoring techniques and one fully-automated refactoring tool not based on heuristic search.

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

[2]  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).

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

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

[5]  Gordon Fraser,et al.  Parameter tuning or default values? An empirical investigation in search-based software engineering , 2013, Empirical Software Engineering.

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

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

[8]  Yuanfang Cai,et al.  Interactive and guided architectural refactoring with search-based recommendation , 2016, SIGSOFT FSE.

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

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

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

[12]  Robert R. Jackson,et al.  Trial-and-error solving of a confinement problem by a jumping spider, Portia fimbriata , 2001 .

[13]  Martin Rinard,et al.  Proceedings of the ACM international conference companion on Object oriented programming systems languages and applications companion , 2010 .

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

[15]  Kent L. Beck,et al.  Test-driven Development - by example , 2002, The Addison-Wesley signature series.

[16]  Kalyanmoy Deb,et al.  Dynamic multiobjective optimization problems: test cases, approximations, and applications , 2004, IEEE Transactions on Evolutionary Computation.

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

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

[19]  Carlos A. Coello Coello,et al.  Evolutionary multiobjective optimization using an outranking-based dominance generalization , 2010, Comput. Oper. Res..

[20]  Kalyanmoy Deb,et al.  An Interactive Evolutionary Multiobjective Optimization Method Based on Progressively Approximated Value Functions , 2010, IEEE Transactions on Evolutionary Computation.

[21]  Mohamed Wiem Mkaouer,et al.  On the use of many quality attributes for software refactoring: a many-objective search-based software engineering approach , 2016, Empirical Software Engineering.

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

[23]  Orit Hazzan,et al.  The Agile Manifesto , 2014 .

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

[25]  Aravind Srinivasan,et al.  Innovization: innovating design principles through optimization , 2006, GECCO.

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

[27]  Mohamed Wiem Mkaouer,et al.  Recommendation system for software refactoring using innovization and interactive dynamic optimization , 2014, ASE.

[28]  A. Vargha,et al.  A Critique and Improvement of the CL Common Language Effect Size Statistics of McGraw and Wong , 2000 .

[29]  Hironori Washizaki,et al.  RefactoringScript: A Script and Its Processor for Composite Refactoring , 2014, SEKE.

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

[31]  William G. Griswold,et al.  WitchDoctor: IDE support for real-time auto-completion of refactorings , 2012, 2012 34th International Conference on Software Engineering (ICSE).

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

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

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

[35]  Gabriele Bavota,et al.  Putting the Developer in-the-Loop: An Interactive GA for Software Re-modularization , 2012, SSBSE.

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

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

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

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

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

[41]  Murat Köksalan,et al.  A Territory Defining Multiobjective Evolutionary Algorithms and Preference Incorporation , 2010, IEEE Transactions on Evolutionary Computation.

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

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

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

[45]  Danny Dig A Refactoring Approach to Parallelism , 2011, IEEE Software.

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

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

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

[49]  Heike Trautmann,et al.  Integration of Preferences in Hypervolume-Based Multiobjective Evolutionary Algorithms by Means of Desirability Functions , 2010, IEEE Transactions on Evolutionary Computation.

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

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

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

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