Skip to main content
Log in

Differential precondition checking: a language-independent, reusable analysis for refactoring engines

  • Published:
Automated Software Engineering Aims and scope Submit manuscript

    We’re sorry, something doesn't seem to be working properly.

    Please try refreshing the page. If that doesn't work, please contact support so we can address the problem.

Abstract

One of the most difficult parts of building automated refactorings is ensuring that they preserve behavior. This paper proposes a new technique to check for behavior preservation; we call this technique differential precondition checking. It is simple yet expressive enough to implement the most common refactorings, and the core algorithm runs in linear time. However, the main advantage is that a differential precondition checker can be placed in a library and reused in refactoring tools for many different languages; the core algorithm can be implemented in a way that is completely language independent. We have implemented a differential precondition checker and used it in refactoring tools for Fortran (Photran), PHP, and BC.

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

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3

Similar content being viewed by others

Notes

  1. http://c2.com/cgi/wiki?RefactoringBenchmarksForExtractMethod.

  2. http://c2.com/cgi/wiki?RefactoringBenchmarksForPullUpMethod.

  3. Why differential “precondition” checking? A refactoring takes user input \(I\) and uses it to determine a program transformation \(T(I)\). However, a precondition for the application of \(T(I)\) to the user’s source code is that it satisfies the properties of compilability and preservation.

  4. Bugs 177636, 194996, 194997, 195002, 195004, 194005, and 195006.

  5. A slightly more complete and much more detailed specification for this refactoring is given in the technical report Overbey et al. (2011) described in the Evaluation section of this paper.

  6. Again, a more complete and detailed specification is available Overbey et al. (2011).

  7. Actually, in practice, the requirement is not so strict: Two tree nodes can correspond to the same textual region as long as only one of them can ever occur as the endpoint of a semantic edge in a program graph.

  8. The tests were performed on a 2.3 GHz Intel Core i7 (MacBook Pro), Java 1.6.0_51, with the JVM heap limited to 512 MB.

References

  • Daniel, B., Dig, D., Garcia, K., Marinov, D.: Automated testing of refactoring engines. In: Proceedings of the the 6th Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on the Foundations of Software Engineering (FSE ’07). ACM, New York, (2007)

  • Dig, D., Marrero, J., Ernst, M.D.: Refactoring sequential Java code for concurrency via concurrent libraries. In: Proceedings of the 31st International Conference on Software Engineering. IEEE Computer Society (ICSE ’09), Washington, DC, pp. 397–407 (2009)

  • Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison Wesley, Reading, MA (1995)

    Google Scholar 

  • Kennedy, Ken, Allen, John R.: Optimizing Compilers for Modern Architectures: A Dependence-Based Approach. Morgan Kaufmann, San Francisco (2002)

    Google Scholar 

  • Mens, Tom, van Eetvelde, N., Demeyer, S., Janssens, D.: Formalizing Refactorings with Graph Transformations. J. Softw. Maint. Evol. 17(4), 247–276 (2005)

    Article  Google Scholar 

  • Murphy-Hill, E., Parnin, C., Black, A.P..: How we refactor, and how we know it. In: Proceedings of the 31st International Conference on Software Engineering (ICSE ’09), pp. 287–297 (2009)

  • Overbey, J.L., Fotzler, M.J., Kasza, A.J., Johnson, R.E.: A Collection of Refactoring Specifications for Fortran 95, BC, and PHP 5. Technical Report http://jeff.over.bz/papers/2011/tr-refacs.pdf (2011)

  • Overbey, J.L., Johnson, R.E.: Differential precondition checking: a lightweight, reusable analysis for refactoring tools. In: 26th IEEE/ACM International Conference on Automated Software Engineering (ASE ’11), pp. 303–312. Lawrence (2011)

  • Overbey, J.L., Johnson, R.E.: Generating rewritable abstract syntax trees. In: Software Language Engineering. Lecture Notes in Computer Science, vol. 5452, pp. 114–133. Springer, Berlin (2008)

  • Reichenbach, C., Coughlin, D., Diwan, A.: Program metamorphosis. In: Proceedings of the 23rd European Conference on Object Oriented Programming (ECOOP ’09) (2009)

  • Schäfer, M., de Moor, O.: Specifying and implementing refactorings. In: ACM Sigplan Notices (SPLASH ’10), vol. 45, pp. 286–301 (2010)

  • Schäfer, M., Dolby, J., Sridharan, M., Tip, F., Torlak, E.: Correct refactoring of concurrent Java code. In: 24th European Conference on Object-Oriented Programming (ECOOP ’10). Springer, Berlin (2010)

  • Schäfer, M., Ekman, T., de Moor, O.: Sound and extensible renaming for Java. In: 23rd Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA ’08). ACM Press, New York (2008)

  • Schäfer, M., Verbaere, M., Ekman, T., de Moor, O.: Stepping stones over the refactoring rubicon—lightweight language extensions to easily realise refactorings. In: ECOOP ’09 (2009)

  • Verbaere, M., Ettinger, R., de Moor, O.: JunGL: a scripting language for refactoring. In: Proceedings of the 28th International Conference on Software Engineering (ICSE’06). ACM, New York (2006)

Download references

Acknowledgments

This research is part of the Blue Waters sustained-petascale computing project, which is supported by the National Science Foundation (Award Number OCI 07-25070) and the state of Illinois. Blue Waters is a joint effort of the University of Illinois at Urbana-Champaign, its National Center for Supercomputing Applications, IBM, and the Great Lakes Consortium for Petascale Computation. Additionally, portions of this research were supported by the National Science Foundation under award CCF-1217271. The authors would like to thank the anonymous reviewers, as well as Rob Bocchino, John Brant, Brett Daniel, Danny Dig, Matthew Fotzler, Milos Gligoric, Vilas Jagannath, Ashley Kasza, Darko Marinov, Stas Negara, and members of the Brett Daniel Software Engineering Seminar for providing invaluable feedback on earlier drafts of this paper.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Jeffrey L. Overbey.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Overbey, J.L., Johnson, R.E. & Hafiz, M. Differential precondition checking: a language-independent, reusable analysis for refactoring engines. Autom Softw Eng 23, 77–104 (2016). https://doi.org/10.1007/s10515-014-0176-9

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10515-014-0176-9

Keywords

Navigation