Abstract
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.
References
- ABADI, A., ETTINGER, R., AND FELDMAN, Y. A. Reapproaching the Refactoring Rubicon. In WRT (2008). Google Scholar
Digital Library
- BECK, K., AND ANDRES, C. Extreme Programming Explained: Embrace Change (2nd Edition). Addison-Wesley Professional, 2004. Google Scholar
Digital Library
- DIG, D., COMERTOGLU, C., MARINOV, D., AND JOHNSON, R. Automated Detection of Refactorings in Evolving Components. In ECOOP (2006). Google Scholar
Digital Library
- Eclipse 4.2. http://www.eclipse.org/eclipse4.Google Scholar
- FOSTER, S. R., GRISWOLD, W. G., AND LERNER, S. WitchDoctor: IDE Support for Real-time Auto-completion of Refactorings. In ICSE (2012). Google Scholar
Digital Library
- FOWLER, M. Refactoring: Improving the Design of Existing Code. Addison Wesley, 2000.Google Scholar
Digital Library
- GE, X., DUBOSE, Q. L., AND MURPHY-HILL, E. R. Reconciling Manual and Automatic Refactoring. In ICSE (2012). Google Scholar
Digital Library
- GRISWOLD, W. G. Program Restructuring as an Aid to Software Maintenance. Ph.D. thesis, University of Washington, 1991. Google Scholar
Digital Library
- GULWANI, S. Dimensions in program synthesis. In ACM PPDP (2010). Google Scholar
Digital Library
- GVERO, T., KUNCAK, V., KURAJ, I., AND PISKAC, R. On Complete Completion using Types and Weights. Tech. Rep. 182807, EPFL, 2012.Google Scholar
- HART, P. E., NILSSON, N. J., AND RAPHAEL, B. A formal basis for the heuristic determination of minimum cost paths. In IEEE Transactions on Systems Science and Cybernetics (1968), IEEE, pp. 100--107.Google Scholar
Cross Ref
- IntelliJ IDEA 12 Community Edition. http://www.jetbrains.com/idea.Google Scholar
- KIM, M., NOTKIN, D., AND GROSSMAN, D. Automatic Inference of Structural Changes for Matching Across Program Versions. In ICSE (2007). Google Scholar
Digital Library
- KUPERSTEIN, M., VECHEV, M., AND YAHAV, E. Automatic inference of memory fences. ACM SIGACT News (2012). Google Scholar
Digital Library
- LAHODA, J., BEČIČKA, J., AND RUIJS, R. B. Custom Declarative Refactoring in NetBeans. In WRT (2012). Google Scholar
Digital Library
- LEE, Y. Y., CHEN, N., AND JOHNSON, R. E. Drag-and-Drop Refactoring: Intuitive and Efficient Program Transformation. In ICSE (2013). Google Scholar
Digital Library
- MANDELIN, D., XU, L., BODÍK, R., AND KIMELMAN, D. Jungloid mining: helping to navigate the API jungle. In ACM PLDI (2005). Google Scholar
Digital Library
- MURPHY-HILL, E. R., AND BLACK, A. P. Breaking the Barriers to Successful Refactoring: Observations and Tools for Extract Method. In ICSE (2008). Google Scholar
Digital Library
- MURPHY-HILL, E. R., PARNIN, C., AND BLACK, A. P. How We Refactor, and How We Know It. TSE 38, 1 (2012). Google Scholar
Digital Library
- NEGARA, S., CHEN, N., VAKILIAN, M., JOHNSON, R. E., AND DIG, D. A Comparative Study of Manual and Automated Refactorings. In ECOOP (2013). Google Scholar
Digital Library
- NetBeans 7.0.1. http://netbeans.org.Google Scholar
- OPDYKE, W. F. Refactoring Object-Oriented Frameworks. Ph.D. thesis, University of Illinois at Urbana-Champaign, 1992. Google Scholar
Digital Library
- PERELMAN, D., GULWANI, S., BALL, T., AND GROSSMAN, D. Type-directed completion of partial expressions. In ACM PLDI (2012). Google Scholar
Digital Library
- PRETE, K., RACHATASUMRIT, N., SUDAN, N., AND KIM, M. Template-based Reconstruction of Complex Refactorings. In ICSM (2010). Google Scholar
Digital Library
- REICHENBACH, C., COUGHLIN, D., AND DIWAN, A. Program Metamorphosis. In ECOOP (2009). Google Scholar
Digital Library
- ROBERTS, D., BRANT, J., AND JOHNSON, R. E. A Refactoring Tool for Smalltalk. TAPOS 3, 4 (1997). Google Scholar
Digital Library
- SCHÄFER, M., VERBAERE, M., EKMAN, T., AND DE MOOR, O. Stepping Stones over the Refactoring Rubicon - Lightweight Language Extensions to Easily Realise Refactorings. In ECOOP (2009).Google Scholar
- SOLAR-LEZAMA, A. The sketching approach to program synthesis. In APLAS (2009). Google Scholar
Digital Library
- SOLAR-LEZAMA, A., JONES, C. G., AND BODIK, R. Sketching concurrent data structures. In ACM PLDI (2008). Google Scholar
Digital Library
- SOLAR-LEZAMA, A., TANCAU, L., BODIK, R., SESHIA, S., AND SARASWAT, V. Combinatorial sketching for finite programs. SIGOPS Oper. Syst. Rev. (2006). Google Scholar
Digital Library
- STEIMANN, F., KOLLEE, C., AND VON PILGRIM, J. A Refactoring Constraint Language and Its Application to Eiffel. In ECOOP (2011). Google Scholar
Digital Library
- STEIMANN, F., AND VON PILGRIM, J. Refactorings Without Names. In ASE (2012). Google Scholar
Digital Library
- TANEJA, K., DIG, D., AND XIE, T. Automated Detection of API Refactorings in Libraries. In ASE (2007). Google Scholar
Digital Library
- THUMMALAPENTA, S., AND XIE, T. Parseweb: a programmer assistant for reusing open source code on the web. In ACM/IEEE ASE (2007). Google Scholar
Digital Library
- VAKILIAN, M., CHEN, N., MOGHADDAM, R. Z., NEGARA, S., AND JOHNSON, R. E. A Compositional Paradigm of Automating Refactorings. In ECOOP (2013). Google Scholar
Digital Library
- VAKILIAN, M., CHEN, N., NEGARA, S., RAJKUMAR, B. A., BAILEY, B. P., AND JOHNSON, R. E. Use, Disuse, and Misuse of Automated Refactorings. In ICSE (2012). Google Scholar
Digital Library
- VECHEV, M., YAHAV, E., AND YORSH, G. Inferring synchronization under limited observability. In TACAS (2009). Google Scholar
Digital Library
- VECHEV, M., YAHAV, E., AND YORSH, G. Abstraction-guided synthesis of synchronization. In ACM POPL (2010). Google Scholar
Digital Library
- VERBAERE, M., ETTINGER, R., AND DE MOOR, O. JunGL: A Scripting Language for Refactoring. In ICSE (2006). Google Scholar
Digital Library
- VERMOLEN, S., WACHSMUTH, G., AND VISSER, E. Reconstructing Complex Metamodel Evolution. In SLE (2011). Google Scholar
Digital Library
- WEISSGERBER, P., AND DIEHL, S. Identifying Refactorings from Source-Code Changes. In ASE (2006). Google Scholar
Digital Library
- XING, Z., AND STROULIA, E. API-Evolution Support with Diff-CatchUp. TSE 33, 12 (2007). Google Scholar
Digital Library
- YESSENOV, K., XU, Z., AND SOLAR-LEZAMA, A. Datadriven synthesis for object-oriented frameworks. In ACM OOPSLA (2011). Google Scholar
Digital Library
Index Terms
Refactoring with synthesis






Comments