Download presentation
Presentation is loading. Please wait.
Published byArline Atkinson Modified over 9 years ago
1
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 1 Towards an Investigation of Opportunities for Refactoring to Design Patterns Norihiro Yoshida, Katsuro Inoue Osaka University
2
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 2 Refactoring Refactoring is a technique for restructuring an existing code[1]. Alter software’s internal structure without changing its external behavior Improve the maintainability of software We have worked on refactoring support for code clone. New method Call statements [1] M. Fowler, Refactoring: improving the design of existing code, Addison Wesley, 1999.
3
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 3 Refactoring to Design Patterns Improve design quality of software that lack of design patterns J. Kerievsky, Refactoring to Patterns, Addison Wesley, 2004. 27 refactoring patterns Refactoring opportunity Procedure for performing refactoring using design pattern J. Rajesh et al., JIAD: A tool to infer design patterns in refactoring, PPDP 2004. M. O. Cinneide et al., A Methodology for the Automated Introduction of Design Patterns, ICSM 1999.
4
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 4 An Example of Refactoring to Design Pattern DOMBuilderTestXMLBuilderTest junit::framework::TestCase testAddAboveRoot ・・・ builder = new DOMBuilder(…); ・・・ builder = new XMLBuilder(…); ・・・ 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.
5
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 5 An Example of Refactoring to Design Pattern Introduce Polymorphic Creation with Factory Method DOMBuilderTestXMLBuilderTest junit::framework::TestCase 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.
6
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 6 Our Research Question and Plan Research Question What kind of refactoring opportunities are involved in software systems? Research Plan Develop an automated tool that identifies opportunities Carry out the investigation using the tool
7
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 7 Automation of Identifying Opportunities DOMBuilderTestXMLBuilderTest junit::framework::TestCase testAddAboveRoot ・・・ builder = new DOMBuilder(…); ・・・ builder = new XMLBuilder(…); ・・・ 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. Step 1 Detect similar methods using a code clone detection tool such as CCFinder Step 2 Evaluate whether detected methods include object creation statements
8
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 8 Investigation points and Anticipated Results Investigation points How many refactoring opportunities exist? Is it possible to improve maintainability by performing refactoring to design patterns? Anticipated Results Quality differences among design patterns A number of refactoring opportunities The degree of change in the maintainability
9
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 9 Summary and Current Status We show a plan for investigating opportunities for refactoring to design patterns. The automated tool that identifies opportunities for refactoring to design patterns Our investigation points and anticipated results We are currently investigating ANTLR. ANTLR 2.7.4 (47,000 LOC, 285 Classes) Open source compiler-compiler Our tool detected 16 opportunities in ANTLR
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.