skip to main content
research-article
Free Access

Constraint-Based Refactoring

Published:03 January 2018Publication History
Skip Abstract Section

Abstract

Constraint-based refactoring generalizes constraint-based type refactoring as introduced by Tip et al. [61] by extending the coverage of change from types to names, locations, accessibilities, and other properties of program elements. Starting with a generic specification of refactoring tools, we systematically develop constraint-based refactoring as a generic solution to a certain class of refactoring problems and provide a condition under which constraint-based refactoring tools are proven correct for any given target language. Although compliance with this correctness condition is hard to prove for target languages whose semantics is not formally defined, we show how the condition gives rise to automated testing procedures. We present a novel algorithm based on constraint-logic programming for the generation of constraints from a program to be refactored, and demonstrate its time and space requirements by using it in the application of refactorings to open source programs. Summarizing earlier work, we show how the principles underlying constraint-based refactoring tools extend to ad hoc refactoring, cross-language refactoring, and model/code co-refactoring.

References

  1. Chris Andreae, James Noble, Shane Markstrum, and Todd D. Millstein. 2006. A framework for implementing pluggable type systems. In Proceedings of the 21th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’06). ACM, New York, NY, 57--74. DOI:https://doi.org/10.1145/1167473.1167479 Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Ittai Balaban, Frank Tip, and Robert M. Fuhrer. 2005. Refactoring support for class library migration. In Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’05). ACM, New York, NY, 265--279. DOI:https://doi.org/10.1145/1094811.1094832 Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Fabian Bannwart and Peter Müller. 2006. Changing programs correctly: Refactoring with specifications. In FM 2006: Formal Methods. Lecture Notes in Computer Science, Vol. 4085. Springer, 492--507. DOI:https://doi.org/10.1007/11813040_33 Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Paulo Borba, Augusto Sampaio, Ana Cavalcanti, and Márcio Cornélio. 2004. Algebraic reasoning for object-oriented programming. Science of Computer Programming 52, 53--100. DOI:https://doi.org/10.1016/j.scico.2004.03.003 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Alan Borning, Robert Duisberg, Bjørn N. Freeman-Benson, Axel Kramer, and Michael Woolf. 1987. Constraint hierarchies. In Proceedings of the Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA’87). ACM, New York, NY, 48--60. DOI:https://doi.org/10.1145/38765.38812 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. John Brant and Friedrich Steimann. 2015. Refactoring tools are trustworthy enough and trust must be earned. IEEE Software 32, 6, 80--83. DOI:https://doi.org/10.1109/MS.2015.145 Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Pascal Brisset, Hani El Sakkout, Thom Frühwirth, Carmen Gervet, Warwick Harvey, Micha Meier, Stefano Novello, Thierry Le Provost, Joachim Schimpf, Kish Shen, and Mark Wallace. 2016. ECLi PSe Constraint Library Manual. Cisco Systems Inc. http://eclipseclp.org/doc/libman.pdf.Google ScholarGoogle Scholar
  8. Randal E. Bryant and Miroslav N. Velev. 2002. Boolean satisfiability with transitivity constraints. ACM Transactions on Computational Logic 3, 4, 604--627. DOI:https://doi.org/10.1145/566385.566390 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Brett Daniel, Danny Dig, Kely Garcia, and Darko Marinov. 2007. Automated testing of refactoring engines. In Proceedings of the 6th Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT International Symposium on Foundations of Software Engineering. ACM, New York, NY, 185--194. DOI:https://doi.org/10.1145/1287624.1287651 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. ECMA-367. 2006. Eiffel: Analysis, Design and Programming Language (2nd ed.). ECMA International. http://www.ecma-international.org/publications/standards/Ecma-367.htm.Google ScholarGoogle Scholar
  11. Stephen R. Foster, William G. Griswold, and Sorin Lerner. 2012. WitchDoctor: IDE support for real-time auto-completion of refactorings. In Proceedings of the 2012 34th International Conference on Software Engineering (ICSE’12). 222--232. DOI:https://doi.org/10.1109/ICSE.2012.6227191 Google ScholarGoogle ScholarCross RefCross Ref
  12. Martin Fowler. 1999. Refactoring—Improving the Design of Existing Code. Addison-Wesley. http://martinfowler.com/books/refactoring.html.Google ScholarGoogle Scholar
  13. Bjørn N. Freeman-Benson, John Maloney, and Alan Borning. 1990. An incremental constraint solver. Communications of the ACM 33, 1, 54--63. DOI:https://doi.org/10.1145/76372.77531 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Robert M. Fuhrer, Frank Tip, Adam Kiezun, Julian Dolby, and Markus Keller. 2005. Efficiently refactoring Java applications to use generic libraries. In ECOOP 2005—Object-Oriented Programming. Lecture Notes in Computer Science, Vol. 3586. Springer, 71--96. DOI:https://doi.org/10.1007/11531142_4 Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Alejandra Garrido and Jose Meseguer. 2006. Formal specification and verification of Java refactorings. In Proceedings of the 6th IEEE International Workshop on Source Code Analysis and Manipulation (SCAM’06). IEEE, Los Alamitos, CA, 165--174. DOI:https://doi.org/10.1109/SCAM.2006.16 Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Xi Ge, Quinton L. DuBose, and Emerson R. Murphy-Hill. 2012. In Proceedings of the 2012 34th International Conference on Software Engineering (ICSE’12). 211--221. DOI:https://doi.org/10.1109/ICSE.2012.6227192 Google ScholarGoogle ScholarCross RefCross Ref
  17. Milos Gligoric, Farnaz Behrang, Yilong Li, Jeffrey Overbey, Munawar Hafiz, and Darko Marinov. 2013. Systematic testing of refactoring engines on real software projects. In ECOOP 2013—Object-Oriented Programming. Lecture Notes in Computer Science, Vol. 7920. Springer, 629--653. DOI:https://doi.org/10.1007/978-3-642-39038-8_26 Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. James Gosling, Bill Joy, Guy L. Steele, Gilad Bracha, and Alex Buckley. 2014. The Java Language Specification, Java SE 8 Edition.Addison-Wesley Professional.Google ScholarGoogle Scholar
  19. William G. Griswold. 1991. Program Restructuring as an Aid to Software Maintenance. Ph.D. Dissertation. University of Washington.Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Christian Grothoff, Jens Palsberg, and Jan Vitek. 2007. Encapsulating objects with confined types. ACM Transactions on Programming Languages and Systems 29, 6, Article No. 32. DOI:https://doi.org/10.1145/1286821.1286823 Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Elnar Hajiyev, Mathieu Verbaere, and Oege de Moor. 2006. codeQuest: Scalable source code queries with datalog. In ECOOP 2006—Object-Oriented Programming. Lecture Notes in Computer Science, Vol. 4067. Springer, 2--27. DOI:https://doi.org/10.1007/11785477_2 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Pascal Van Hentenryck. 1989. Constraint Satisfaction in Logic Programming. MIT Press, Cambridge, MA.Google ScholarGoogle Scholar
  23. Pascal Van Hentenryck and Laurent Michel. 2005. Constraint-Based Local Search. MIT Press, Cambridge, MA.Google ScholarGoogle Scholar
  24. C. A. R. Hoare. 1969. An axiomatic basis for computer programming. Communications of the ACM 12, 10, 576--580. DOI:https://doi.org/10.1145/363235.363259 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Hannes Kegel and Friedrich Steimann. 2008. Systematically refactoring inheritance to delegation in Java. In Proceedings of the 30th International Conference on Software Engineering (ICSE’08). ACM, New York, NY, 431--440. DOI:https://doi.org/10.1145/1368088.1368147 Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Adam Kiezun, Michael D. Ernst, Frank Tip, and Robert M. Fuhrer. 2007. Refactoring for parameterizing Java classes. In Proceedings of the 29th International Conference on Software Engineering (ICSE’07). IEEE, Los Alamitos, CA, 437--446. DOI:https://doi.org/10.1109/ICSE.2007.70 Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Donald E. Knuth. 1968. Semantics of context-free languages. Mathematical Systems Theory 2, 2, 127--145. DOI:https://doi.org/10.1007/BF01692511 Google ScholarGoogle ScholarCross RefCross Ref
  28. Tiago Massoni, Rohit Gheyi, and Paulo Borba. 2006. An approach to invariant-based program refactoring. Electronic Communications of the EASST 3, 1--12. http://eceasst.cs.tu-berlin.de/index.php/eceasst/article/view/25.Google ScholarGoogle Scholar
  29. Tom Mens, Niels Van Eetvelde, Serge Demeyer, and Dirk Janssens. 2005. Formalizing refactorings with graph transformations. Journal of Software Maintenance 17, 4, 247--276. DOI:https://doi.org/10.1002/smr.316 Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Tom Mens and Tom Tourwé. 2004. A survey of software refactoring. IEEE Transactions on Software Engineering 30, 2, 126--139. DOI:https://doi.org/10.1109/TSE.2004.1265817 Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Marcus Mews. 2016. Kontrollflusssensible Quelltext-Umgestaltung mithilfe von Constraint-Programmierung (in German). Ph.D. Dissertation. Technische Universität Berlin. http://dx.doi.org/10.14279/depositonce-5444.Google ScholarGoogle Scholar
  32. Scott Meyers, Carolyn K. Duby, and Steven P. Reiss. 1993. Constraining the structure and style of object-oriented programs. In Proceedings of the 1st Workshop on Principles and Practice of Constraint Programming (PPCP’93). 200--209.Google ScholarGoogle Scholar
  33. Microsoft. 2003. C# Language Specification. Retrieved November 9, 2017, from http://www.microsoft.com/en-us/download/details.aspx?id=7029.Google ScholarGoogle Scholar
  34. OMG. 2012. About the Object Constraint Language Specification Version 2.4. Specification. Retrieved November 9, 2017, from http://www.omg.org/spec/OCL/.Google ScholarGoogle Scholar
  35. William F. Opdyke. 1992. Refactoring Object-Oriented Frameworks. Ph.D. Dissertation. University of Illinois at Urbana-Champaign.Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Jeffrey L. Overbye. 2011. A Toolkit for Constructing Refactoring Engines. Ph.D. Dissertation. University of Illinois at Urbana-Champaign.Google ScholarGoogle Scholar
  37. Jens Palsberg and Michael I. Schwartzbach. 1994. Object-Oriented Type Systems. Wiley.Google ScholarGoogle Scholar
  38. Veselin Raychev, Max Schäfer, Manu Sridharan, and Martin T. Vechev. 2013. Refactoring with synthesis. In Proceedings of the Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA’13). ACM, New York, NY, 339--354. DOI:https://doi.org/10.1145/2509136.2509544 Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Donald Bradley Roberts. 1999. Practical Analysis for Refactoring. Ph.D. Dissertation. University of Illinois at Urbana-Champaign.Google ScholarGoogle Scholar
  40. Max Schäfer. 2010. Specification, Implementation and Verification of Refactorings. Ph.D. Dissertation. Oxford University Computing Laboratory. http://progtools.comlab.ox.ac.uk/members/xiemaisi/thesis.Google ScholarGoogle Scholar
  41. Max Schäfer and Oege de Moor. 2010. Specifying and implementing refactorings. In Proceedings of the Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA’10). ACM, New York, NY, 286--301. DOI:https://doi.org/10.1145/1869459.1869485 Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Max Schäfer, Julian Dolby, Manu Sridharan, Emina Torlak, and Frank Tip. 2010. Correct refactoring of concurrent Java code. In ECOOP 2010—Object-Oriented Programming. Lecture Notes in Computer Science, Vol. 6183. Springer, 225--249. DOI:https://doi.org/10.1007/978-3-642-14107-2_11 Google ScholarGoogle ScholarCross RefCross Ref
  43. Max Schäfer, Torbjörn Ekman, and Oege de Moor. 2008. Sound and extensible renaming for Java. In Proceedings of the Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA’08). ACM, New York, NY, 277--294. DOI:https://doi.org/10.1145/1449764.1449787 Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Max Schäfer, Andreas Thies, Friedrich Steimann, and Frank Tip. 2012. A comprehensive approach to naming and accessibility in refactoring Java programs. IEEE Transactions on Software Engineering 38, 6, 1233--1257. DOI:https://doi.org/10.1109/TSE.2012.13 Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Max Schäfer, Mathieu Verbaere, Torbjörn Ekman, and Oege de Moor. 2009. Stepping stones over the refactoring rubicon In Proceedings of the 23rd European Conference on ECOOP2009—Object-Oriented Programming (ECOOP’09). 369--393. DOI:https://doi.org/10.1007/978-3-642-03013-0_17 Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Joachim Schimpf. 2002. Logical loops. In Logic Programming. Lecture Notes in Computer Science, Vol. 2401. Springer, 224--238. DOI:https://doi.org/10.1007/3-540-45619-8_16 Google ScholarGoogle ScholarCross RefCross Ref
  47. Gustavo Soares, Rohit Gheyi, and Tiago Massoni. 2013. Automated behavioral testing of refactoring engines. IEEE Transactions on Software Engineering 39, 2, 147--162. DOI:https://doi.org/10.1109/TSE.2012.19 Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Gustavo Soares, Melina Mongiovi, and Rohit Gheyi. 2011. Identifying overly strong conditions in refactoring implementations. In Proceedings of the IEEE 27th International Conference on Software Maintenance (ICSM’11). IEEE, Los Alamitos, CA, 173--182. DOI:https://doi.org/10.1109/ICSM.2011.6080784 Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Friedrich Steimann. 2015. From well-formedness to meaning preservation: Model refactoring for almost free. Software and System Modeling 14, 1, 307--320. DOI:https://doi.org/10.1007/s10270-013-0314-z Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. Friedrich Steimann. 2015. Refactoring tools and their kin. In Grand Timely Topics in Software Engineering. Lecture Notes in Computer Science, Vol. 10223. Springer, 179--214. DOI:https://doi.org/10.1007/978-3-319-60074-1_8 Google ScholarGoogle ScholarCross RefCross Ref
  51. Friedrich Steimann, Jörg Hagemann, and Bastian Ulke. 2016. Computing repair alternatives for malformed programs using constraint attribute grammars. In Proceedings of the Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA’16). ACM, New York, NY, 711--730. DOI:https://doi.org/10.1145/2983990.2984007 Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. Friedrich Steimann, Christian Kollee, and Jens von Pilgrim. 2011. A refactoring constraint language and its application to Eiffel. In ECOOP 2011—Object-Oriented Programming. Lecture Notes in Computer Science, Vol. 6813. Springer, 255--280. DOI:https://doi.org/10.1007/978-3-642-22655-7_13 Google ScholarGoogle ScholarCross RefCross Ref
  53. Friedrich Steimann and Andreas Thies. 2009. From public to private to absent: Refactoring Java programs under constrained accessibility. In Genoa Proceedings of the 23rd European Conference on ECOOP 2009—Object-Oriented Programming (ECOOP’09). 419--443. DOI:https://doi.org/10.1007/978-3-642-03013-0_19 Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. Friedrich Steimann and Jens von Pilgrim. 2012. Constraint-based refactoring with foresight. In ECOOP 2012--Object-Oriented Programming. Lecture Notes in Computer Science, Vol. 7313. Springer, 535--559. DOI:https://doi.org/10.1007/978-3-642-31057-7_24 Google ScholarGoogle ScholarDigital LibraryDigital Library
  55. Friedrich Steimann and Jens von Pilgrim. 2012. Refactorings without names. In Proceedings of the IEEE/ACM International Conference on Automated Software Engineering (ASE’12). ACM, New York, NY, 290--293. DOI:https://doi.org/10.1145/2351676.2351726 Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. Nik Sultana and Simon J. Thompson. 2008. Mechanical verification of refactorings. In Proceedings of the 2008 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation (PEPM’08). ACM, New York, NY, 51--60. DOI:https://doi.org/10.1145/1328408.1328417 Google ScholarGoogle ScholarDigital LibraryDigital Library
  57. Andreas Thies. 2014. Constraintbasierte Refaktorisierung von Deklarationen in Java. Ph.D. Dissertation. Lehrgebiet Programmiersysteme, Fakultät für Mathematik und Informatik, FernUniversität in Hagen. https://ub-deposit.fernuni-hagen.de/receive/mir_mods_00000464.Google ScholarGoogle Scholar
  58. Andreas Thies and Eric Bodden. 2012. RefaFlex: Safer refactorings for reflective Java programs. In Proceedings of the International Symposium on Software Testing and Analysis (ISSTA’12). ACM, New York, NY, 1--11. DOI:https://doi.org/10.1145/2338965.2336754 Google ScholarGoogle ScholarDigital LibraryDigital Library
  59. Andreas Thies and Friedrich Steimann. 2010. Systematic testing of refactoring tools (poster). In Proceedings of the 5th Workshop on Automation of Software Test (AST’10). http://www.fernuni-hagen.de/ps/prjs/rtt/rtt_poster.pdf.Google ScholarGoogle Scholar
  60. Simon J. Thompson and Huiqing Li. 2013. Refactoring tools for functional languages. Journal of Functional Programming 23, 3, 293--350. DOI:https://doi.org/10.1017/S0956796813000117 Google ScholarGoogle ScholarCross RefCross Ref
  61. Frank Tip, Robert M. Fuhrer, Adam Kiezun, Michael D. Ernst, Ittai Balaban, and Bjorn De Sutter. 2011. Refactoring using type constraints. ACM Transactions on Programming Languages and Systems 33, 3, 9. DOI:https://doi.org/10.1145/1961204.1961205 Google ScholarGoogle ScholarDigital LibraryDigital Library
  62. Frank Tip, Adam Kiezun, and Dirk Bäumer. 2003. Refactoring for generalization using type constraints. In Proceedings of the Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA’03). ACM, New York, NY, 13--26. DOI:https://doi.org/10.1145/949305.949308 Google ScholarGoogle ScholarDigital LibraryDigital Library
  63. Bastian Ulke and Friedrich Steimann. 2013. OCL as a constraint generation language. In Proceedings of the MODELS 2013 OCL Workshop Co-Located With the 16th International ACM/IEEE Conference on Model Driven Engineering Languages and Systems (MODELS’13). CEUR Workshop Proceedings, Vol. 1092. 93--102. http://ceur-ws.org/Vol-1092/ulke.pdf.Google ScholarGoogle Scholar
  64. Bastian Ulke, Friedrich Steimann, and Ralf Lämmel. 2017. Partial evaluation of OCL expressions. In Proceedings of the ACM/IEEE 20th International Conference on Model Driven Engineering Languages and Systems. IEEE, Los Alamitos, CA.Google ScholarGoogle ScholarDigital LibraryDigital Library
  65. Mohsen Vakilian, Nicholas Chen, Stas Negara, Balaji Ambresh Rajkumar, Brian P. Bailey, and Ralph E. Johnson. 2012. Use, disuse, and misuse of automated refactorings. In Proceedings of the 34th International Conference on Software Engineering (ICSE’12). 233--243. DOI:https://doi.org/10.1109/ICSE.2012.6227190 Google ScholarGoogle ScholarCross RefCross Ref
  66. Mathieu Verbaere, Ran Ettinger, and Oege de Moor. 2006. JunGL: A scripting language for refactoring. In Proceedings of the 28th International Conference on Software Engineering (ICSE’06). ACM, New York, NY, 172--181. DOI:https://doi.org/10.1145/1134311Google ScholarGoogle ScholarDigital LibraryDigital Library
  67. Jens von Pilgrim, Bastian Ulke, Andreas Thies, and Friedrich Steimann. 2013. Model/code co-refactoring: An MDE approach. In Proceedings of the 2013 28th IEEE/ACM International Conference on Automated Software Engineering (ASE’13). IEEE, Los Alamitos, CA, 682--687. DOI:https://doi.org/10.1109/ASE.2013.6693133 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Constraint-Based Refactoring

          Recommendations

          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 Transactions on Programming Languages and Systems
            ACM Transactions on Programming Languages and Systems  Volume 40, Issue 1
            March 2018
            157 pages
            ISSN:0164-0925
            EISSN:1558-4593
            DOI:10.1145/3173093
            Issue’s Table of Contents

            Copyright © 2018 ACM

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 3 January 2018
            • Accepted: 1 July 2017
            • Revised: 1 May 2017
            • Received: 1 September 2016
            Published in toplas Volume 40, Issue 1

            Permissions

            Request permissions about this article.

            Request Permissions

            Check for updates

            Qualifiers

            • research-article
            • Research
            • Refereed

          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!