Abstract
Refactorings change the internal structure of code without changing its external behavior. For non-trivial refactorings, the preservation of external behavior depends on semantic properties of the program that are difficult to check automatically before the refactoring is applied. Therefore, existing refactoring tools either do not support non-trivial refactorings at all or force programmers to rely on (typically incomplete) test suites to check their refactorings.
The technique presented in the paper allows one to show the preservation of external behavior even for complex refactorings. For a given refactoring, we prove once and for all that the refactoring is an equivalence transformation, provided that the refactored program satisfies certain semantic correctness conditions. These conditions can be added automatically as assertions to the refactored program and checked at runtime or verified statically. Our technique allows tools to apply even complex refactorings safely, and refactorings automatically improve program documentation by generating assertions.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Banerjee, A., Naumann, D.A.: Ownership confinement ensures representation independence for object-oriented programs. J. ACM 52(6), 894–960 (2005)
Bannwart, F.: Changing software correctly. Technical Report 509, Department of Computer Science, ETH Zürich (2006)
Barnett, M., Leino, K.R.M., Schulte, W.: The Spec# Programming System: An Overview. In: Barthe, G., Burdy, L., Huisman, M., Lanet, J.-L., Muntean, T. (eds.) CASSIS 2004. LNCS, vol. 3362, pp. 49–69. Springer, Heidelberg (2005)
Bergstein, P.L.: Object-preserving class transformations. In: OOPSLA, pp. 299–313. ACM Press, New York (1991)
Clarke, D.G., Potter, J.M., Noble, J.: Ownership types for flexible alias protection. In: OOPSLA, pp. 48–64. ACM Press, New York (1998)
Cornélio, M.: Refactorings as Formal Refinements. PhD thesis, Universidade de Pernambuco (2004)
Dietl, W., Müller, P.: Universes: Lightweight ownership for JML. Journal of Object Technology (JOT) 4(8), 5–32 (2005)
Fähndrich, M., DeLine, R.: Adoption and focus: practical linear types for imperative programming. In: PLDI, pp. 13–24. ACM Press, New York (2002)
Fähndrich, M., Leino, K.R.M.: Declaring and checking non-null types in an object-oriented language. In: OOPSLA, pp. 302–312. ACM Press, New York (2003)
Fowler, M.: Refactoring: improving the design of existing code. Addison-Wesley, Reading (1999)
Gheyi, R., Massoni, T., Borba, P.: An abstract equivalence notion for object models. Electr. Notes Theor. Comput. Sci. 130, 3–21 (2005)
Kerievsky, J.: Refactoring to Patterns. Addison-Wesley Professional, Reading (2004)
Kiniry, J.R., Cok, D.R.: ESC/Java2: Uniting ESC/Java and JML. In: Barthe, G., Burdy, L., Huisman, M., Lanet, J.-L., Muntean, T. (eds.) CASSIS 2004. LNCS, vol. 3362, pp. 108–128. Springer, Heidelberg (2005)
Lämmel, R.: Towards Generic Refactoring. In: Workshop on Rule-Based Programming (RULE). ACM Press, New York (2002)
Leavens, G.T., Baker, A.L., Ruby, C.: Preliminary design of JML: A behavioral interface specification language for Java. Technical Report 98-06-rev28, Iowa State University (2005)
Leino, K.R.M., Müller, P.: Object invariants in dynamic contexts. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 491–515. Springer, Heidelberg (2004)
Lieberherr, K.J., Hürsch, W.L., Xiao, C.: Object-extending class transformations. Formal Aspects of Computing (6), 391–416 (1994)
Logozzo, F., Cortesi, A.: Semantic hierarchy refactoring by abstract interpretation. In: Emerson, E.A., Namjoshi, K.S. (eds.) VMCAI 2006. LNCS, vol. 3855, pp. 313–331. Springer, Heidelberg (2005)
Morgan, C.: Programming from specifications. Prentice-Hall, Englewood Cliffs (1990)
Opdyke, W.F.: Refactoring object-oriented frameworks. PhD thesis, University of Illinois at Urbana-Champaign (1992)
Roberts, D.B.: Practical analysis for refactoring. PhD thesis, University of Illinois at Urbana-Champaign (1999)
Streckenbach, M., Snelting, G.: Refactoring class hierarchies with KABA. In: OOPSLA, pp. 315–330. ACM Press, New York (2004)
Tokuda, L., Batory, D.: Evolving object-oriented designs with refactorings. In: Automated Software Engineering, pp. 174–182. IEEE Computer Society, Los Alamitos (1999)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2006 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Bannwart, F., Müller, P. (2006). Changing Programs Correctly: Refactoring with Specifications. In: Misra, J., Nipkow, T., Sekerinski, E. (eds) FM 2006: Formal Methods. FM 2006. Lecture Notes in Computer Science, vol 4085. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11813040_33
Download citation
DOI: https://doi.org/10.1007/11813040_33
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-37215-8
Online ISBN: 978-3-540-37216-5
eBook Packages: Computer ScienceComputer Science (R0)