Download presentation
Presentation is loading. Please wait.
Published byEdwin Elliott Modified over 9 years ago
1
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 1 Towards an Assessment of the Quality of Refactoring Patterns Norihiro Yoshida, Masatomo Yoshida, Katsuro Inoue Osaka University, Japan
2
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 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
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 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 3
4
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 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)http://refactoring.com/ J. Kerievsky, Refactoring to Patterns. Addison Wesley, 2004. (27 patterns) 4 However, the quality of each refactoring pattern is mostly never assessed.
5
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 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 5 [1] J. Kerievsky, Refactoring to Patterns. Addison Wesley, 2004
6
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 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”. 6
7
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 7 Case Study Target Refactoring Pattern (1/2) DOMBuilderTestXMLBuilderTest junit::framework::TestCase testAddAboveRoot ・・・ builder = new DOMBuilder(…); ・・・ builder = new XMLBuilder(…); ・・・ We assess the quality characteristics of Introduce Polymorphic Creation with Factory Method. Before Refactoring Condition 1 Similar methods belong to classes that have a common parent class. Condition 2 Only difference among similar methods is an object creation step.
8
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 8 Case Study Target Refactoring Pattern (2/2) DOMBuilderTestXMLBuilderTest testAddAboveRoot ・・・ builder = new DOMBuilder(…); ・・・ builder = new XMLBuilder(…); ・・・ AbstractBuilderTest junit::framework::TestCase createBuilder #builder: OutputBuilder testAddAboveRoot ・・・ builder = new createBuilder(“orders”); ・・・ DOMBuilderTestXMLBuilderTest Factory Method: Creator Factory Method: ConcreteCreator return new DOMBuilder(…); return new XMLBuilder(…); createBuilder Before RefactoringAfter Refactoring It’s easy to add new test class. junit::framework::TestCase We assess the quality characteristics of Introduce Polymorphic Creation with Factory Method.
9
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 9 Case Study Automation of Identifying Opportunities DOMBuilderTestXMLBuilderTest junit::framework::TestCase testAddAboveRoot ・・・ builder = new DOMBuilder(…); ・・・ builder = new XMLBuilder(…); ・・・ Before Refactoring Condition 1 Similar methods belong to classes that have a common parent class. Condition 2 Only difference among similar methods is an object creation step. Step 1 Detect similar methods using a code clone detection tool CCFinder Step 2 Evaluate whether detected methods include object creation statements We developed an automated tool that identifies opportunities.
10
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Case Study Number of Refactoring Opportunities 10 TargetLOC# classes# opportunities Target PatternPull Up Method ANTLR32K167133 Ant198K994223 Azureus538K22262042 jEdit168K92201 JHotDraw90K487126 SableCC35K23701 Soot352K2298553 WALA210K1565722 Developers should inspect whether refactoring opportunities for Pull Up Method are also are also for Introduce Polymorphic Creation with Factory Method. 17.9% of the refactoring opportunities for Pull Up Method are also for Introduce Polymorphic Creation with Factory Method.
11
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Case Study Ease of Refactoring 1. Apply the target pattern to the refactoring opportunities in Ant and ANTLR. 2. Confirm the steps that are not described in the description of the target pattern. 11 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
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 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 12
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.