
Assessment of Refactoring Patterns Quality: Research Insights
Explore research on the quality assessment of refactoring patterns in software development, including characteristics like number of opportunities and ease of refactoring. Learn about proposed quality metrics and a case study on a specific refactoring pattern.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Towards an Assessment of the Quality of Refactoring Patterns Norihiro Yoshida, Masatomo Yoshida, Katsuro Inoue Osaka University, Japan Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 1
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 2 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 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) J. Kerievsky, Refactoring to Patterns. Addison Wesley, 2004. (27 patterns) However, the quality of each refactoring pattern is mostly never assessed. 4 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 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University [1] J. Kerievsky, Refactoring to Patterns. Addison Wesley, 2004 5
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 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University
Case Study Target 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( ); 7 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University
Case Study Target 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 DOMBuilderTest XMLBuilderTest createBuilder builder = new createBuilder( orders ); testAddAboveRoot It s easy to add new test class. testAddAboveRoot testAddAboveRoot Factory Method: ConcreteCreator builder = new DOMBuilder( ); DOMBuilderTest XMLBuilderTest createBuilder createBuilder builder = new XMLBuilder( ); return new DOMBuilder( ); return new XMLBuilder( ); 8 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University
Case Study Automation 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( ); 9 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University
Case Study Number of Refactoring Opportunities Target LOC # classes # opportunities Target Pattern Pull Up Method 17.9% of the refactoring opportunities for Pull Up Method are also for Introduce Polymorphic Creation with Factory Method. ANTLR Ant Azureus jEdit JHotDraw SableCC Soot WALA Method. 32K 198K 538K 168K 90K 35K 352K 210K 167 994 2226 922 487 237 2298 1565 1 2 33 23 42 1 26 1 53 22 20 0 1 0 5 7 Developers should inspect whether refactoring opportunities for Pull Up Method are also are also for Introduce Polymorphic Creation with Factory 10 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. 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. 11 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 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University