Automated support for program refactoring using invariants

Yoshio Kataoka, Michael D. Ernst, William G. Griswold, David Notkin

2002 · 170 citations · 19 references

Concepts

TL;DR

Program refactoring, which improves readability, structure, performance, abstraction, and maintainability, is underutilized largely because identifying suitable candidates and selecting appropriate transformations is costly. This study demonstrates that it is feasible to automatically locate program locations that are suitable for specific refactorings. By detecting invariant patterns with Daikon and matching them against predefined refactoring templates, the authors automatically identified refactoring opportunities in a Java codebase. The approach uncovered numerous refactoring opportunities, and a developer of the codebase evaluated their effectiveness.

Abstract

Program refactoring-transforming a program to improve readability, structure, performance, abstraction, maintainability, or other features-is not applied in practice as much as might be desired. One deterrent is the cost of detecting candidates for refactoring and of choosing the appropriate refactoring transformation. This paper demonstrates the feasibility of automatically finding places in the program that are candidates for specific refactorings. The approach uses program invariants: when a particular pattern of invariant relationships appears at a program point, a specific refactoring is applicable. Since most programs lack explicit invariants, an invariant detection tool called Daikon is used to infer the required invariants. We developed an invariant pattern matcher for several common refactorings and applied it to an existing Java code base. Numerous refactorings were detected, and one of the developers of the code base assessed their efficacy.

References

19