Automated refactoring to the Strategy design pattern

被引:28
作者
Christopoulou, Aikaterini [1 ]
Giakoumakis, E. A. [1 ]
Zafeiris, Vassilis E. [1 ]
Soukara, Vasiliki [2 ]
机构
[1] Athens Univ Econ & Business, Dept Informat, Athens 10434, Greece
[2] Informat Soc SA, Ymittos 17237, Greece
关键词
Refactoring; Design patterns; Strategy pattern; Polymorphism; Total replacement of conditional logic; IDENTIFICATION; OPPORTUNITIES;
D O I
10.1016/j.infsof.2012.05.004
中图分类号
TP [自动化技术、计算机技术];
学科分类号
0812 ;
摘要
Context: The automated identification of code fragments characterized by common design flaws (or "code smells") that can be handled through refactoring, fosters refactoring activities, especially in large code bases where multiple developers are engaged without a detailed view on the whole system. Automated refactoring to design patterns enables significant contributions to design quality even from developers with little experience on the use of the required patterns. Objective: This work targets the automated identification of refactoring opportunities to the Strategy design pattern and the elimination through polymorphism of respective "code smells" that are related to extensive use of complex conditional statements. Method: An algorithm is introduced for the automated identification of refactoring opportunities to the Strategy design pattern. Suggested refactorings comprise conditional statements that are characterized by analogies to the Strategy design pattern, in terms of the purpose and selection mode of strategies. Moreover, this work specifies the procedure for refactoring to Strategy the identified conditional statements. For special cases of these statements, a technique is proposed for total replacement of conditional logic with method calls of appropriate concrete Strategy instances. The identification algorithm and the refactoring procedure are implemented and integrated in the JDeodorant Eclipse plug-in. The method is evaluated on a set of Java projects, in terms of quality of the suggested refactorings and run-time efficiency. The relevance of the identified refactoring opportunities is verified by expert software engineers. Results: The identification algorithm recalled, from the projects used during evaluation, many of the refactoring candidates that were identified by the expert software engineers. Its execution time on projects of varying size confirmed the run-time efficiency of this method. Conclusion: The proposed method for automated refactoring to Strategy contributes to simplification of conditional statements. Moreover, it enhances system extensibility through the Strategy design pattern. (c) 2012 Elsevier B.V. All rights reserved.
引用
收藏
页码:1202 / 1214
页数:13
相关论文
共 28 条
[1]  
Apache Software Foundation, 2012, NUTCH WEB SEARCH SOF
[2]  
Apache Software Foundation, 2012, ANT TOOL SOFTW BUILD
[3]  
Chatzigeorgiou A., 2011, JDEODORANT ECLIPSE P
[4]  
Cinneide M. O., 1999, Proceedings IEEE International Conference on Software Maintenance - 1999 (ICSM'99). `Software Maintenance for Business Change' (Cat. No.99CB36360), P463, DOI 10.1109/ICSM.1999.792644
[5]  
Demeyer S., 2008, SOFTWARE EVOLUTION, P91
[6]   THE PROGRAM DEPENDENCE GRAPH AND ITS USE IN OPTIMIZATION [J].
FERRANTE, J ;
OTTENSTEIN, KJ ;
WARREN, JD .
ACM TRANSACTIONS ON PROGRAMMING LANGUAGES AND SYSTEMS, 1987, 9 (03) :319-349
[7]  
Fowler M., 2018, Refactoring: Improving the Design of Existing Code
[8]  
Freeman E., 2004, Head First Design Patterns: A Brain-Friendly Guide
[9]  
Gamma E., 1995, DESIGN PATTERNS ELEM
[10]  
Horstmann C.S., 2012, VIOLET OPEN SOURCE U