Refactoring with synthesis

Refactoring has become an integral part of modern software development, with wide support in popular integrated development environments (IDEs). Modern IDEs provide a fixed set of supported refactorings, listed in a refactoring menu. But with IDEs supporting more and more refactorings, it is becoming increasingly difficult for programmers to discover and memorize all their names and meanings. Also, since the set of refactorings is hard-coded, if a programmer wants to achieve a slightly different code transformation, she has to either apply a (possibly non-obvious) sequence of several built-in refactorings, or just perform the transformation by hand. We propose a novel approach to refactoring, based on synthesis from examples, which addresses these limitations. With our system, the programmer need not worry how to invoke individual refactorings or the order in which to apply them. Instead, a transformation is achieved via three simple steps: the programmer first indicates the start of a code refactoring phase; then she performs some of the desired code changes manually; and finally, she asks the tool to complete the refactoring. Our system completes the refactoring by first extracting the difference between the starting program and the modified version, and then synthesizing a sequence of refactorings that achieves (at least) the desired changes. To enable scalable synthesis, we introduce local refactorings, which allow for first discovering a refactoring sequence on small program fragments and then extrapolating it to a full refactoring sequence. We implemented our approach as an Eclipse plug-in, with an architecture that is easily extendable with new refactorings. The experimental results are encouraging: with only minimal user input, the synthesizer was able to quickly discover complex refactoring sequences for several challenging realistic examples.

[1]  Ralph E. Johnson,et al.  Drag-and-drop refactoring: Intuitive and efficient program transformation , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[2]  Armando Solar-Lezama,et al.  Data-driven synthesis for object-oriented frameworks , 2011, OOPSLA '11.

[3]  Stas Negara,et al.  Use, disuse, and misuse of automated refactorings , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[4]  Yishai A. Feldman,et al.  Re-approaching the refactoring Rubicon , 2008, WRT '08.

[5]  Stas Negara,et al.  A Compositional Paradigm of Automating Refactorings , 2013, ECOOP.

[6]  Eleni Stroulia,et al.  API-Evolution Support with Diff-CatchUp , 2007, IEEE Transactions on Software Engineering.

[7]  Eran Yahav,et al.  Inferring Synchronization under Limited Observability , 2009, TACAS.

[8]  Eran Yahav,et al.  Automatic inference of memory fences , 2010, Formal Methods in Computer Aided Design.

[9]  Tao Xie,et al.  Automated detection of api refactorings in libraries , 2007, ASE '07.

[10]  Ralph E. Johnson,et al.  Automated Detection of Refactorings in Evolving Components , 2006, ECOOP.

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

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

[13]  Sander Vermolen,et al.  Reconstructing Complex Metamodel Evolution , 2011, SLE.

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

[15]  Ralph E. Johnson,et al.  A Refactoring Tool for Smalltalk , 1997, Theory Pract. Object Syst..

[16]  Emerson R. Murphy-Hill,et al.  Reconciling manual and automatic refactoring , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[17]  Kent Beck,et al.  Extreme Programming Explained: Embrace Change (2nd Edition) , 2004 .

[18]  Amer Diwan,et al.  Program Metamorphosis , 2009, ECOOP.

[19]  Max Schaefer,et al.  Stepping Stones over the Refactoring Rubicon – Lightweight Language Extensions to Easily Realise Refactorings , 2009 .

[20]  Eran Yahav,et al.  Abstraction-guided synthesis of synchronization , 2010, POPL.

[21]  Armando Solar-Lezama,et al.  Sketching concurrent data structures , 2008, PLDI '08.

[22]  Kent L. Beck,et al.  Extreme programming explained - embrace change , 1990 .

[23]  Sumit Gulwani,et al.  Type-directed completion of partial expressions , 2012, PLDI.

[24]  Jan Lahoda,et al.  Custom declarative refactoring in NetBeans: tool demonstration , 2012, WRT '12.

[25]  Rastislav Bodík,et al.  Jungloid mining: helping to navigate the API jungle , 2005, PLDI '05.

[26]  Stephan Diehl,et al.  Identifying Refactorings from Source-Code Changes , 2006, 21st IEEE/ACM International Conference on Automated Software Engineering (ASE'06).

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

[28]  William G. Griswold Program restructuring as an aid to software maintenance , 1992 .

[29]  Sanjit A. Seshia,et al.  Combinatorial sketching for finite programs , 2006, ASPLOS XII.

[30]  Sumit Gulwani,et al.  Dimensions in program synthesis , 2010, Formal Methods in Computer Aided Design.

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

[32]  Friedrich Steimann,et al.  Refactorings without names , 2012, 2012 Proceedings of the 27th IEEE/ACM International Conference on Automated Software Engineering.

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

[34]  Armando Solar-Lezama,et al.  The Sketching Approach to Program Synthesis , 2009, APLAS.

[35]  Tao Xie,et al.  Parseweb: a programmer assistant for reusing open source code on the web , 2007, ASE.

[36]  Ruzica Piskac,et al.  Complete completion using types and weights , 2013, PLDI.

[37]  Nils J. Nilsson,et al.  A Formal Basis for the Heuristic Determination of Minimum Cost Paths , 1968, IEEE Trans. Syst. Sci. Cybern..

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

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

[40]  Miryung Kim,et al.  Automatic Inference of Structural Changes for Matching across Program Versions , 2007, 29th International Conference on Software Engineering (ICSE'07).