Making Program Refactoring Safer
Resumo
Developers rely on compilation, test suite and tools to preserve observable behavior during refactorings. However, most of the refactoring tools do not implement all preconditions that guarantee behavioral preservation, since formally identifying them is cost-prohibitive. Therefore, these tools may change the behavior of the user’s code. We propose two approaches for making program refactoring safer. We present an approach and its implementation (SAFEREFACTOR) useful for improving the developer’s confidence that the refactoring was correctly applied. It analyzes a transformation and generates tests specific for detecting behavioral changes. Moreover, we propose an approach to help refactoring tool developers to test their implementations. This approach evaluates an implementation by automatically generating programs (test inputs), and checking the results with SAFEREFACTOR. We evaluated SAFEREFACTOR in transformations applied to seven real programs ranging from 3 to 100 KLOC. In one of them (JHotDraw), we identified a behavioral change that was not revealed so far. On the other hand, we evaluated the second approach by testing 22 refactoring implementations in two Java refactoring tools: the Eclipse Refactoring Module and the JastAdd Refactoring Tool. We analyzed more than 80K transformations, and identified 67 bugs.
Referências
Daniel, B., Dig, D., Garcia, K., and Marinov, D. (2007). Automated testing of refactoring engines. In FSE ’07, pages 185–194.
Fowler, M. (1999). Refactoring: Improving the Design of Existing Code. Addison-Wesley.
Jackson, D. (2006). Software Abstractions: Logic, Language and Analysis. MIT press.
Mens, T. and Tourwé, T. (2004). A survey of software refactoring. IEEE Transactions on Software Engineering, 30(2):126–139.
Schäfer, M., , and de Moor, O. (2010). Specifying and implementing refactorings. In OOPSLA ’10, pages 286–301.
Schäfer, M., Ekman, T., and de Moor, O. (2008). Sound and extensible renaming for Java. In OOPSLA ’08, pages 277–294.
Schäfer, M., Ekman, T., and de Moor, O. (2009a). Challenge proposal: Verification of refactorings. In PLPV ’09, pages 67–72.
Schäfer, M., Verbaere, M., Ekman, T., and Moor, O. (2009b). Stepping stones over the refactoring rubicon. In ECOOP ’09, pages 369–393.
Silva, L., Sampaio, A., and Liu, Z. (2008). Laws of object-orientation with reference semantics. In SEFM ’08, pages 217–226.
Soares, G. (2010a). Making program refactoring safer. In Student Research Competition at ICSE ’10, pages 521–522.
Soares, G. (2010b). Making program refactoring safer. In XVII Latin-American Master Thesis Contest CLTM 2010 at CLEI ’10.
Soares, G., Cavalcanti, D., Gheyi, R., Massoni, T., Serey, D., and Cornélio, M. (2009a). SafeRefactor - tool for checking refactoring safety. In Tools Session at SBES, pages 49–54.
Soares, G., Gheyi, R., Massoni, T., Cornélio, M., and Cavalcanti, D. (2009b). Generating unit tests for checking refactoring safety. In SBLP, pages 159–172.
Soares, G., Gheyi, R., Serey, D., and Massoni, T. (2010). Making program refactoring safer. IEEE Software, 27:52–57.
Steimann, F. and Thies, A. (2009). From public to private to absent: Refactoring Java programs under constrained accessibility. In ECOOP ’09, pages 419–443.
Tip, F., Kiezun, A., and Baumer, D. (2003). Refactoring for Generalization Using Type Constraints. In OOPSLA ’03, pages 13–26.