Towards an Assessment of the Quality of Refactoring Patterns

Refactoring is a well-known process that is thought to improve the maintainability of object-oriented software. Although a lot of refactoring patterns are introduced in several pieces of literature, the quality of refactoring patterns is not always discussed. Therefore, it is difficult for developers to determine which refactoring patterns should be given priority. In this paper, we propose two quality characteristics of refactoring pattern, and then describe an open source case study on assessing those quality characteristics. Keywords-refactoring; quality of software pattern; objectoriented programing; software maintenance; I. I NTRODUCTION Refactoring [1] is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure. That is to say, refactoring is a process to improve the maintainability of software systems. Several practitioners introduce a lot of Refactoring Patterns (RP) [1][2]. Each RP includes both a description of a refactoring opportunity (RO) (i.e., a set of code fragments that should be refactored) and the corresponding procedure to perform refactoring (i.e., how to perform refactoring). However, the quality of each refactoring pattern is mostly never assessed. Therefore, it is difficult for developers to determine which refactoring patterns should be given priority. In this paper, we propose two quality characteristics of RPs, and then describe a case study on assessing those quality characteristics. II. PROPOSED QUALITY CHARACTERISTICS OF REFACTORING PATTERNS We introduce the following two quality characteristics of RP. • Number of ROs: Because a lot of refactoring patterns exist and developers have only a limited time, it is desirable to choose RPs that have a lot of ROs. • Ease of Refactoring: It means that ease of applying each RP to ROs in source code. When the ease of refactoring of a RP is high, it means that software systems involve a lot of ROs that can be easily performed refactoring. A RP that is difficult to apply often leads to time-consuming refactoring. Because the aim of refactoring is to reduce maintenance cost, time-consuming refactoring is not desirable. There are two kinds of refactoring pattern. The first one requires developers to apply only steps described in its description. On the other hand, another sometimes requires developers to apply not only steps described in its description but also additional steps. III. C ASE STUDY In this section, we assess the quality characteristics of RP which is namedIntroduce Polymorphic Creation with Factory Method (IPCFM) [2]. We introduce IPCFM and an automated method to identify ROs in software systems for IPCFM. Then, we discuss the ROs in several software systems from proposed quality characteristics of RP. A. Introduce polymorphic creation with factory method IPCFM is a kind ofPull up Method [1] pattern that is aimed at merging similar methods from different classes into a common superclass. Figure 1 shows an example of IPCFM. The aim of IPCFM is to merge similar methods except for object creation statements by introducing factory methods. An RO for IPCFM is defined as“Classes in a hierarchy implement a method similarly except for an object creation step” [2]. As shown in Figure 1(a), the targets of the refactoring are the test classes DOMBuilderTest andXMLBuilderTest for testingDOMBuilder andXMLBuilder, respectively. Because the target classes have similar methods except for an object creation step, they indicate an RO for applying IPCFM. This refactoring is comprised of following two steps. Step1 As shown in Figure 1(b), a common superclass (AbstractBuilderTest) for the target classes is introduced, and similar methods in the target classes are merged into new method in the common superclass. Step2 A factory method is introduced in each of the common superclass ( AbstractBuilderTest) and the subclasses ( DOMBuilderTest and XMLBuilderTest). B. Assessment Method For our case study, we have developed the tool that identifies ROs for the target RP by the steps below.