Automated method-extraction refactoring by using block-based slicing
Katsuhisa Maruyama · 2001
Refactoring improves the design of existing code but is not complex to do by hand. This paper proposes a mechanism that automatically refactors methods of object-oriented programs by using program slicing. To restructure a method without changing its observable behavior, the mechanism uses block-based slicing that does not extract the fragments of code from the whole program but from the region consisting of some consecutive basic-blocks of the program. A refactoring tool implementing the mechanism constructs a new method that contains the extracted code and re-forms the source method that contains this tool, a programmer indicates only a variable of interest in the code that he/she wants to refactor and then selects a suitable method from among the candidates created by the tool. The programmer does not have to test the refactored code since the mechanism is based on data-and control-flow analysis. Thus the tool enables programmers to avoid manual refactoring whose process is error-prone and time-consuming