Skip to main content

Refactoring Tools and Their Kin

  • Conference paper
  • First Online:
Grand Timely Topics in Software Engineering (GTTSE 2015)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 10223))

Abstract

Refactoring is the process of changing a program in such a way that its design improves with respect to some specific goal, while its observable behaviour remains the same. Trivially, the latter includes the preservation of the program’s well-formedness, since arguably, a malformed program has no behaviour to be preserved.

While the problem of refactoring is easily stated, casting it into fully functional refactoring tools for contemporary programming languages is surprisingly hard. In fact, most refactoring tools in use today cannot even guarantee to preserve well-formedness, let alone behaviour, not even for some of the most basic refactorings (such as Rename or Pull Up Member).

In Part I of this briefing, I will report on some of the most promising techniques for implementing correct refactoring tools. Common to these techniques is that they give up the notion of behaviour preservation in favour of the more basic (and less demanding) notion of invariant preservation: to be correct, a refactoring tool must not accidentally change the binding of names, the overriding of methods, the synchronization on a monitor, etc. Preservation of well-formedness is then the preservation of invariants relating to well-formedness.

With invariant preservation tackled, it is straightforward to transfer refactoring technology to other programming tools, including tools for automatic repair and completion of programs, mutation testing, and program generation. How these are related to refactoring tools, and how they can be developed in concert, I will propose in Part II of this briefing.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    I have gathered some first-hand experience with this, which drove me to lamenting “whenever we believed that we had made correctness of the refactoring plausible, testing it on a new project revealed a new problem we had not previously thought of” [24].

  2. 2.

    Practitioners may find this precondition too strong. Indeed, it seems that it could be relaxed to requiring well-formedness only for the parts of the program that are in some way connected to the intended refactoring. However, it seems difficult, if not impossible, to decide if a malformed part of a program is connected to a refactoring. For example, what if the refactoring makes the formerly malformed part well-formed, for instance by renaming a declared element so that a formerly unbound reference now binds to this element?

  3. 3.

    This includes instanceof tests, which will become ill-typed.

  4. 4.

    In a study conducted by the author, dynamic dispatching affected 41%, and synchronization affected 3.5% of all attempted applications of Replace Inheritance with Delegation [24].

  5. 5.

    In the same study [24], they prevented 84% of all naive refactoring applications in four subject programs.

  6. 6.

    I freely admit that I spent one summer trying to understand what it takes to cover Java’s generics in every detail, and gave up highly frustrated.

  7. 7.

    Note the relationship to projectional editing, which uses references, or pointers, rather than names.

  8. 8.

    In fact, for efficiency reasons, it may not be advisable to use standard constraint solving for this purpose. However, efficient one-way computations may be synthesized from n-way constraints [22]. A conventionally implemented lookup function is a good use case for this. See also at the end of Sect. 9 in Part II of this briefing, where this issue is picked up again.

  9. 9.

    This greatly oversimplifies matters — see [38] for a more thorough account of accessibility in Java.

  10. 10.

    See [41] for some more details on how Skolemization relates well-formedness checking and binding.

  11. 11.

    Note that we do not consider syntax errors here.

References

  1. Andreae, C., Noble, J., Markstrum, S., Millstein, T.D.: A framework for implementing pluggable type systems. In: Tarr, P.L., Cook, W.R. (eds.) Proceedings of the 21th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2006, 22–26 October 2006, Portland, Oregon, USA, pp. 57–74. ACM (2006). http://doi.acm.org/10.1145/1167473.1167479

  2. Balaban, I., Tip, F., Fuhrer, R.M.: Refactoring support for class library migration. In: Johnson, R.E., Gabriel, R.P. (eds.) Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2005, 16–20 October 2005, San Diego, CA, USA, pp. 265–279. ACM (2005). http://doi.acm.org/10.1145/1094811.1094832

  3. Bannwart, F., Müller, P.: Changing programs correctly: refactoring with specifications. In: Misra, J., Nipkow, T., Sekerinski, E. (eds.) FM 2006. LNCS, vol. 4085, pp. 492–507. Springer, Heidelberg (2006). doi:10.1007/11813040_33

    Chapter  Google Scholar 

  4. Beck, K.: Extreme Programming Explained: Embrace Change. Addison-Wesley Longman Publishing Co. Inc., Boston (2000)

    Google Scholar 

  5. Borba, P., Sampaio, A., Cavalcanti, A., Cornélio, M.: Algebraic reasoning for object-oriented programming. Sci. Comput. Program. 52, 53–100 (2004). http://dx.doi.org/10.1016/j.scico.2004.03.003

    Article  MathSciNet  MATH  Google Scholar 

  6. Bracha, G.: Pluggable type systems. In: OOPSLA Workshop on Revival of Dynamic Languages, vol. 1. Citeseer (2004)

    Google Scholar 

  7. Brant, J., Steimann, F.: Refactoring tools are trustworthy enough and trust must be earned. IEEE Softw. 32(6), 80–83 (2015). http://dx.doi.org/10.1109/MS.2015.145

    Article  Google Scholar 

  8. Daniel, B., Dig, D., Garcia, K., Marinov, D.: Automated testing of refactoring engines. In: Crnkovic, I., Bertolino, A. (eds.) Proceedings of the 6th Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT International Symposium on Foundations of Software Engineering, 2007, Dubrovnik, Croatia, 3–7 September 2007, pp. 185–194. ACM (2007). http://doi.acm.org/10.1145/1287624.1287651

  9. Dietl, W., Dietzel, S., Ernst, M.D., Muslu, K., Schiller, T.W.: Building and using pluggable type-checkers. In: Taylor, R.N., Gall, H.C., Medvidovic, N. (eds.) Proceedings of the 33rd International Conference on Software Engineering, ICSE 2011, Waikiki, Honolulu, HI, USA, 21–28 May 2011, pp. 681–690. ACM (2011). http://doi.acm.org/10.1145/1985793.1985889

  10. Dig, D., Marrero, J., Ernst, M.D.: Refactoring sequential Java code for concurrency via concurrent libraries. In: 31st International Conference on Software Engineering, ICSE 2009, 16–24 May 2009, Vancouver, Canada, Proceedings, pp. 397–407. IEEE (2009). http://dx.doi.org/10.1109/ICSE.2009.5070539

  11. Foster, S.R., Griswold, W.G., Lerner, S.: Witchdoctor: IDE support for real-time auto-completion of refactorings. In: Glinz et al. [16], pp. 222–232. http://dx.doi.org/10.1109/ICSE.2012.6227191

  12. Fowler, M.: Refactoring - Improving the Design of Existing Code. Addison Wesley Object Technology Series. Addison-Wesley, Boston (1999)

    MATH  Google Scholar 

  13. Garrido, A., Meseguer, J.: Formal specification and verification of Java refactorings. In: Proceedings of the Sixth IEEE International Workshop on Source Code Analysis and Manipulation, SCAM 2006, pp. 165–174 (2006). http://dx.doi.org/10.1109/SCAM.2006.16

  14. Ge, X., DuBose, Q.L., Murphy-Hill, E.R.: Reconciling manual and automatic refactoring. In: Glinz et al. [16], pp. 211–221. http://dx.doi.org/10.1109/ICSE.2012.6227192

  15. Gligoric, M., Behrang, F., Li, Y., Overbey, J., Hafiz, M., Marinov, D.: Systematic testing of refactoring engines on real software projects. In: Castagna, G. (ed.) ECOOP 2013. LNCS, vol. 7920, pp. 629–653. Springer, Heidelberg (2013). doi:10.1007/978-3-642-39038-8_26

    Chapter  Google Scholar 

  16. Glinz, M., Murphy, G.C., Pezzè, M. (eds.): 34th International Conference on Software Engineering, ICSE 2012, 2–9 June 2012, Zurich, Switzerland. IEEE (2012)

    Google Scholar 

  17. González, C.A., Büttner, F., Clarisó, R., Cabot, J.: EMFtoCSP: a tool for the lightweight verification of EMF models. In: Gnesi, S., Gruner, S., Plat, N., Rumpe, B. (eds.) Proceedings of the First International Workshop on Formal Methods in Software Engineering - Rigorous and Agile Approaches, FormSERA 2012, Zurich, Switzerland, 2 June 2012, pp. 44–50. IEEE (2012). http://dx.doi.org/10.1109/FormSERA.2012.6229788

  18. Griswold, W.G.: Program restructuring as an aid to software maintenance. Ph.D. thesis, University of Washington (1991)

    Google Scholar 

  19. Griswold, W.G., Notkin, D.: Automated assistance for program restructuring. ACM Trans. Softw. Eng. Methodol. 2(3), 228–269 (1993). http://doi.acm.org/10.1145/152388.152389

    Article  Google Scholar 

  20. Grothoff, C., Palsberg, J., Vitek, J.: Encapsulating objects with confined types. ACM Trans. Program. Lang. Syst. 29(6) (2007). http://doi.acm.org/10.1145/1286821.1286823

  21. Heuzeroth, D., Aßmann, U., Trifu, M., Kuttruff, V.: The COMPOST, COMPASS, Inject/J and RECODER tool suite for invasive software composition: invasive composition with compass aspect-oriented connectors. In: Lämmel, R., Saraiva, J., Visser, J. (eds.) GTTSE 2005. LNCS, vol. 4143, pp. 357–377. Springer, Heidelberg (2006). doi:10.1007/11877028_14

    Chapter  Google Scholar 

  22. Hottelier, T., Bodík, R.: Synthesis of layout engines from relational constraints. In: Aldrich, J., Eugster, P. (eds.) Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2015, part of SPLASH 2015, Pittsburgh, PA, USA, 25–30 October 2015, pp. 74–88. ACM (2015). http://doi.acm.org/10.1145/2814270.2814291

  23. Huang, S.S., Zook, D., Smaragdakis, Y.: Statically safe program generation with safegen. Sci. Comput. Program. 76(5), 376–391 (2011). http://dx.doi.org/10.1016/j.scico.2008.09.007

    Article  MathSciNet  MATH  Google Scholar 

  24. Kegel, H., Steimann, F.: Systematically refactoring inheritance to delegation in Java. In: Schäfer, W., Dwyer, M.B., Gruhn, V. (eds.) 30th International Conference on Software Engineering (ICSE 2008), Leipzig, Germany, 10–18 May 2008, pp. 431–440. ACM (2008). http://doi.acm.org/10.1145/1368088.1368147

  25. Knuth, D.E.: Semantics of context-free languages. Math. Syst. Theory 2(2), 127–145 (1968). http://dx.doi.org/10.1007/BF01692511

    Article  MathSciNet  MATH  Google Scholar 

  26. Lämmel, R.: Towards generic refactoring. In: Fischer, B., Visser, E. (eds.) Proceedings of the 2002 ACM SIGPLAN Workshop on Rule-Based Programming, Pittsburgh, Pennsylvania, USA, 2002, pp. 15–28. ACM (2002). http://doi.acm.org/10.1145/570186.570188

  27. Ludwig, A., Heuzeroth, D.: Metaprogramming in the large. In: Butler, G., Jarzabek, S. (eds.) GCSE 2000. LNCS, vol. 2177, pp. 179–188. Springer, Heidelberg (2001). doi:10.1007/3-540-44815-2_13

    Chapter  Google Scholar 

  28. Murphy-Hill, E.R., Parnin, C., Black, A.P.: How we refactor, and how we know it. IEEE Trans. Softw. Eng. 38(1), 5–18 (2012). http://doi.ieeecomputersociety.org/10.1109/TSE.2011.41

    Article  Google Scholar 

  29. Opdyke, W.F.: Refactoring object-oriented frameworks. Ph.D. thesis, University of Illinois at Urbana-Champaign (1992)

    Google Scholar 

  30. Opdyke, W.F., Johnson, R.E.: Creating abstract superclasses by refactoring. In: Kwasny, S.C., Buck, J.F. (eds.) Proceedings of the ACM 21th Conference on Computer Science, CSC 1993, Indianapolis, IN, USA, 16–18 February 1993, pp. 66–73. ACM (1993). http://doi.acm.org/10.1145/170791.170804

  31. Overbye, J.L.: A toolkit for constructing refactoring engines. Ph.D. thesis, University of Illinois at Urbana-Champaign (2011)

    Google Scholar 

  32. Palsberg, J., Schwartzbach, M.I.: Object-Oriented Type Systems. Wiley Professional Computing. Wiley, Chichester (1994)

    MATH  Google Scholar 

  33. Raychev, V., Schäfer, M., Sridharan, M., Vechev, M.T.: Refactoring with synthesis. In: Hosking, A.L., Eugster, P.T., Lopes, C.V. (eds.) Proceedings of the 2013 ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages & Applications, OOPSLA 2013, part of SPLASH 2013, Indianapolis, IN, USA, 26–31 October 2013, pp. 339–354. ACM (2013). http://doi.acm.org/10.1145/2509136.2509544

  34. Roberts, D., Brant, J., Johnson, R.E.: A refactoring tool for Smalltalk. TAPOS 3(4), 253–263 (1997)

    Google Scholar 

  35. Roberts, D.B.: Practical analysis for refactoring. Ph.D. thesis, University of Illinois at Urbana-Champaign (1999)

    Google Scholar 

  36. Schäfer, M.: Specification, implementation and verification of refactorings. Ph.D. thesis, Oxford University Computing Laboratory (2010)

    Google Scholar 

  37. Schäfer, M., de Moor, O.: Of gnats and dragons: sources of complexity in implementing refactorings. In: Workshop on Refactoring Tools (WRT) (2009)

    Google Scholar 

  38. Schäfer, M., Thies, A., Steimann, F., Tip, F.: A comprehensive approach to naming and accessibility in refactoring Java programs. IEEE Trans. Softw. Eng. 38(6), 1233–1257 (2012). http://doi.ieeecomputersociety.org/10.1109/TSE.2012.13

    Article  Google Scholar 

  39. Soares, G., Gheyi, R., Massoni, T.: Automated behavioral testing of refactoring engines. IEEE Trans. Softw. Eng. 39(2), 147–162 (2013). http://dx.doi.org/10.1109/TSE.2012.19

    Article  Google Scholar 

  40. Soares, G., Mongiovi, M., Gheyi, R.: Identifying overly strong conditions in refactoring implementations. In: IEEE 27th International Conference on Software Maintenance, ICSM 2011, Williamsburg, VA, USA, 25–30 September 2011, pp. 173–182. IEEE Computer Society (2011). http://dx.doi.org/10.1109/ICSM.2011.6080784

  41. Steimann, F.: From well-formedness to meaning preservation: model refactoring for almost free. Softw. Syst. Model. 14(1), 307–320 (2015). http://dx.doi.org/10.1007/s10270-013-0314-z

    Article  Google Scholar 

  42. Steimann, F., Hagemann, J., Ulke, B.: Computing repair alternatives for malformed programs using constraint attribute grammars. In: Visser, E., Smaragdakis, Y. (eds.) Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2016, part of SPLASH 2016, Amsterdam, The Netherlands, 30 October – 4 November 2016, pp. 711–730. ACM (2016). http://doi.acm.org/10.1145/2983990.2984007

  43. Steimann, F., von Pilgrim, J.: Constraint-based refactoring with foresight. In: Noble, J. (ed.) ECOOP 2012. LNCS, vol. 7313, pp. 535–559. Springer, Heidelberg (2012). doi:10.1007/978-3-642-31057-7_24

    Chapter  Google Scholar 

  44. Steimann, F., von Pilgrim, J.: Refactorings without names. In: Goedicke, M., Menzies, T., Saeki, M. (eds.) IEEE/ACM International Conference on Automated Software Engineering, ASE 2012, Essen, Germany, 3–7 September 2012, pp. 290–293. ACM (2012). http://doi.acm.org/10.1145/2351676.2351726

  45. Steimann, F., Thies, A.: From public to private to absent: refactoring Java programs under constrained accessibility. In: Drossopoulou, S. (ed.) ECOOP 2009. LNCS, vol. 5653, pp. 419–443. Springer, Heidelberg (2009). doi:10.1007/978-3-642-03013-0_19

    Chapter  Google Scholar 

  46. Steimann, F., Ulke, B.: Generic model assist. In: Moreira, A., Schätz, B., Gray, J., Vallecillo, A., Clarke, P. (eds.) MODELS 2013. LNCS, vol. 8107, pp. 18–34. Springer, Heidelberg (2013). doi:10.1007/978-3-642-41533-3_2

    Chapter  Google Scholar 

  47. Sultana, N., Thompson, S.J.: Mechanical verification of refactorings. In: Glück, R., de Moor, O. (eds.) Proceedings of the 2008 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation, PEPM 2008, San Francisco, California, USA, 7–8 January 2008, pp. 51–60. ACM (2008). http://doi.acm.org/10.1145/1328408.1328417

  48. Tip, F., Fuhrer, R.M., Kiezun, A., Ernst, M.D., Balaban, I., Sutter, B.D.: Refactoring using type constraints. ACM Trans. Program. Lang. Syst. 33(3), 9 (2011). http://doi.acm.org/10.1145/1961204.1961205

    Article  Google Scholar 

  49. Tip, F., Kiezun, A., Bäumer, D.: Refactoring for generalization using type constraints. In: Crocker, R., Jr., G.L.S. (eds.) Proceedings of the 2003 ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages and Applications, OOPSLA 2003, 26–30 October 2003, Anaheim, CA, USA, pp. 13–26. ACM (2003). http://doi.acm.org/10.1145/949305.949308

  50. Vakilian, M., Chen, N., Negara, S., Rajkumar, B.A., Bailey, B.P., Johnson, R.E.: Use, disuse, and misuse of automated refactorings. In: Glinz et al. [16], pp. 233–243. http://dx.doi.org/10.1109/ICSE.2012.6227190

Download references

Acknowledgements

The work presented in this briefing has been supported by Deutsche Forschungsgemeinschaft (DFG) under grants STE 906/4-1&2 and STE 906/5-1. I thank Andreas Thies, Jens von Pilgrim, Frank Tip, Max Schäfer, and Bastian Ulke for their collaboration.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Friedrich Steimann .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Springer International Publishing AG

About this paper

Cite this paper

Steimann, F. (2017). Refactoring Tools and Their Kin. In: Cunha, J., Fernandes, J., Lämmel, R., Saraiva, J., Zaytsev, V. (eds) Grand Timely Topics in Software Engineering. GTTSE 2015. Lecture Notes in Computer Science(), vol 10223. Springer, Cham. https://doi.org/10.1007/978-3-319-60074-1_8

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-60074-1_8

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-60073-4

  • Online ISBN: 978-3-319-60074-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics