Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article

Refactoring with synthesis

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

Cited By

View all
  • (2024)Multilingual Program Code Classification Using $n$-Layered Bi-LSTM Model With Optimized HyperparametersIEEE Transactions on Emerging Topics in Computational Intelligence10.1109/TETCI.2023.33369208:2(1452-1468)Online publication date: Apr-2024
  • (2023)Grace: Language Models Meet Code EditsProceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering10.1145/3611643.3616253(1483-1495)Online publication date: 30-Nov-2023
  • (2023)Dynamically Relative Position Encoding-Based Transformer for Automatic Code EditIEEE Transactions on Reliability10.1109/TR.2022.319437072:3(1147-1160)Online publication date: Sep-2023
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

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
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 29 October 2013
Published in SIGPLAN Volume 48, Issue 10

Check for updates

Author Tags

  1. refactoring
  2. synthesis

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)18
  • Downloads (Last 6 weeks)1
Reflects downloads up to 19 Feb 2025

Other Metrics

Citations

Cited By

View all
  • (2024)Multilingual Program Code Classification Using $n$-Layered Bi-LSTM Model With Optimized HyperparametersIEEE Transactions on Emerging Topics in Computational Intelligence10.1109/TETCI.2023.33369208:2(1452-1468)Online publication date: Apr-2024
  • (2023)Grace: Language Models Meet Code EditsProceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering10.1145/3611643.3616253(1483-1495)Online publication date: 30-Nov-2023
  • (2023)Dynamically Relative Position Encoding-Based Transformer for Automatic Code EditIEEE Transactions on Reliability10.1109/TR.2022.319437072:3(1147-1160)Online publication date: Sep-2023
  • (2023)Composite refactoring: Representations, characteristics and effects on software projectsInformation and Software Technology10.1016/j.infsof.2022.107134156(107134)Online publication date: Apr-2023
  • (2023)Code Semantics Learning with Deep Neural Networks: An AI-Based Approach for Programming EducationComputational Science – ICCS 202310.1007/978-3-031-36030-5_57(737-750)Online publication date: 3-Jul-2023
  • (2022)CODIT: Code Editing With Tree-Based Neural ModelsIEEE Transactions on Software Engineering10.1109/TSE.2020.302050248:4(1385-1399)Online publication date: 1-Apr-2022
  • (2021)One thousand and one stories: a large-scale survey of software refactoringProceedings of the 29th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering10.1145/3468264.3473924(1303-1313)Online publication date: 20-Aug-2021
  • (2021)SOARProceedings of the 43rd International Conference on Software Engineering10.1109/ICSE43902.2021.00023(112-124)Online publication date: 22-May-2021
  • (2020)Characterizing and Identifying Composite RefactoringsProceedings of the 17th International Conference on Mining Software Repositories10.1145/3379597.3387477(186-197)Online publication date: 29-Jun-2020
  • (2020)Refactoring operations Grounded in manual code changesProceedings of the ACM/IEEE 42nd International Conference on Software Engineering: Companion Proceedings10.1145/3377812.3381395(182-185)Online publication date: 27-Jun-2020
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media