1 / 9

Towards an Investigation of Opportunities for Refactoring to Design Patterns

Towards an Investigation of Opportunities for Refactoring to Design Patterns. Norihiro Yoshida , Katsuro Inoue Osaka University. Refactoring. Refactoring is a technique for restructuring an existing code[1]. Alter software’s internal structure without changing its external behavior

kyoko
Télécharger la présentation

Towards an Investigation of Opportunities for Refactoring to Design 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 Investigation of Opportunities for Refactoring to Design Patterns Norihiro Yoshida, Katsuro Inoue 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. 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. An Example of Refactoring to Design Pattern • Introduce Polymorphic Creation with Factory Method Condition 1 Similar methods belong to classes that have a common parent class. Before Refactoring junit::framework::TestCase DOMBuilderTest XMLBuilderTest testAddAboveRoot testAddAboveRoot Condition 2 Only difference among similar methods is an object creation step. ・・・ builder = new DOMBuilder(…); ・・・ ・・・ builder = new XMLBuilder(…); ・・・

  5. An Example of Refactoring to Design Pattern • 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(…);

  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. Automation of Identifying Opportunities • Introduce Polymorphic Creation with Factory Method 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 such as 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(…); ・・・

  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. 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

More Related