Static composition of refactorings

  • Authors:
  • Günter Kniesel;Helge Koch

  • Affiliations:
  • Institute of Computer Science III, University of Bonn, Römerstr. 164, D-53117 Bonn, Germany;Technisch-mathematische studiengesellschaft mbH, Holtorfer Strasse 54, 53229 Bonn, Germany and Institute of Computer Science III, University of Bonn, Römerstr. 164, D-53117 Bonn, Germany

  • Venue:
  • Science of Computer Programming - Special issue on program transformation
  • Year:
  • 2004

Quantified Score

Hi-index 0.00

Visualization

Abstract

The number of possible refactorings is unlimited, so no tool vendor will ever be able to provide custom refactorings for all specific user needs. Therefore, we propose a new kind of refactoring tools, which allow users to create, edit and compose required refactorings just like any other documents. The heart of such a refactoring editor is the ability to compose larger refactorings from existing ones. Computing the precondition of the composite refactoring from the preconditions of the composed refactorings is non-trivial since earlier transformations influence the truth of preconditions of later ones. The ability to calculate these effects without referring to a particular program to which the refactorings should be applied is called program-independent composition. It is the prerequisite for creating composite refactorings that are reusable on arbitrary programs. The main contribution of this paper is a formal model for automatic, program-independent composition of conditional program transformations. We show that conditional transformations, including refactorings, can be composed flom a limited set of basic operations. Program-independent derivation of a precondition for the composite is based on the notion of "transformation description", which can be seen as a simplified, yet equally powerful, variant of Roberts' "postconditions" (Practical analysis for refactoring, Ph.D. Thesis (1999)). Our approach simplifies the implementation of refactoring tools--only the basic operations and the ability for composition must be hard coded in a tool. As a proof of concept, we sketch a transformation framework that implements our approach (jConditioner) and, based on the framework, an experimental refactoring tool (ConTraCT) that includes the editing capabilities that motivated our work.