1 / 12

Towards an Assessment of the Quality of Refactoring Patterns

Towards an Assessment of the Quality of Refactoring Patterns. Norihiro Yoshida , Masatomo Yoshida, Katsuro Inoue Osaka University, Japan. Refactoring . Refactoring is a process of restructuring an existing code.

inara
Download Presentation

Towards an Assessment of the Quality of Refactoring Patterns

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Towards an Assessment of the Quality of Refactoring Patterns Norihiro Yoshida, Masatomo Yoshida, Katsuro Inoue Osaka University, Japan

  2. Refactoring • Refactoring is a process of restructuring an existing code. • Alter software’s internal structure without changing its external behavior • Improve the maintainability of software • Example of Refactoring • Merging code clones into a new method New method Call statements

  3. Refactoring Pattern • Typical process of restructuring existing code • Extract Method, Pull Up Method, Extract Class • Each refactoring pattern includes • refactoring opportunity (bad smell) • a set of code fragments that should be refactored • procedure to perform refactoring • how to perform refactoring

  4. Literatures for Refactoring Patterns • A lot of refactoring patterns are proposed in several literatures. • M. Fowler, Refactoring: improving the design of existing code. Addison Wesley, 1999. • M. Fowler, http://refactoring.com/(93 patterns) • J. Kerievsky, Refactoring to Patterns. Addison Wesley, 2004. (27 patterns) However, the quality of each refactoring pattern is mostly never assessed.

  5. Overview of Our Research • Propose the following quality characteristics of refactoring patterns • Number of Refactoring Opportunities • Ease of Refactoring • Perform a case study on assessing those quality characteristics • A case study on Introduce Polymorphic Creation with Factory Method [1] that is a kind of Pull Up Method [1] J. Kerievsky, Refactoring to Patterns. Addison Wesley, 2004

  6. Propose Quality Characteristics of Refactoring Patterns • Number of Refactoring Opportunities • What kind of refactoring opportunities are involved in software systems? • Ease of Refactoring • It means that ease of applying each refactoring pattern to refactoring opportunities in source code. • We focus on “Whether or not each refactoring pattern involves enough description to perform refactoring easily”.

  7. Case StudyTarget Refactoring Pattern (1/2) • We assess the quality characteristics of Introduce Polymorphic Creation with Factory Method. Before Refactoring junit::framework::TestCase Condition 1 Similar methods belong to classes that have a common parent class. DOMBuilderTest XMLBuilderTest testAddAboveRoot testAddAboveRoot Condition 2 Only difference among similar methods is an object creation step. ・・・ builder = new DOMBuilder(…); ・・・ ・・・ builder = new XMLBuilder(…); ・・・

  8. Case StudyTarget Refactoring Pattern (2/2) • We assess the quality characteristics of Introduce Polymorphic Creation with Factory Method. Before Refactoring After Refactoring junit::framework::TestCase junit::framework::TestCase Factory Method: Creator AbstractBuilderTest #builder: OutputBuilder ・・・ builder = new createBuilder(“orders”); ・・・ DOMBuilderTest XMLBuilderTest createBuilder It’s easy to add new test class. testAddAboveRoot testAddAboveRoot testAddAboveRoot Factory Method: ConcreteCreator ・・・ builder = new DOMBuilder(…); ・・・ DOMBuilderTest XMLBuilderTest createBuilder createBuilder ・・・ builder = new XMLBuilder(…); ・・・ return new DOMBuilder(…); return new XMLBuilder(…);

  9. Case StudyAutomation of Identifying Opportunities • We developed an automated tool that identifies opportunities. Condition 1 Similar methods belong to classes that have a common parent class. Before Refactoring junit::framework::TestCase Step 1 Detect similar methods using a code clone detection tool CCFinder DOMBuilderTest XMLBuilderTest testAddAboveRoot testAddAboveRoot Condition 2 Only difference among similar methods is an object creation step. ・・・ builder = new DOMBuilder(…); ・・・ Step 2 Evaluate whether detected methods include object creation statements ・・・ builder = new XMLBuilder(…); ・・・

  10. Case StudyNumber of Refactoring Opportunities 17.9% of the refactoring opportunities for Pull Up Methodare also for Introduce Polymorphic Creation with Factory Method. Developers should inspect whether refactoring opportunities for Pull Up Methodare also are also for Introduce Polymorphic Creation with Factory Method.

  11. Case StudyEase of Refactoring • Apply the target pattern to the refactoring opportunities in Ant and ANTLR. • Confirm the steps that are not described in the description of the target pattern. We did not have to apply additional steps that are not described in the description of the target pattern. In terms of the ease of refactoring, the quality of the pattern presentation is enough.

  12. Summary & Future Work • Summary • Two quality characteristics of refactoring patterns • A case study on assessing those quality characteristics • Future Work • Assess other refactoring patterns • To compare refactoring patterns in terms of proposed quality characteristics • Discuss change in maintainability

More Related