research-article

Refactoring with synthesis

Published:29 October 2013Publication History

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

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

Index Terms

  1. Refactoring with synthesis

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 48, Issue 10
      OOPSLA '13
      October 2013
      867 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2544173
      Issue’s Table of Contents
      • cover image ACM Conferences
        OOPSLA '13: Proceedings of the 2013 ACM SIGPLAN international conference on Object oriented programming systems languages & applications
        October 2013
        904 pages
        ISBN:9781450323741
        DOI:10.1145/2509136

      Copyright © 2013 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 29 October 2013

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!