Automated pattern-directed refactoring for complex conditional statements
Wei Liu , Zhi-gang Hu , Hong-tao Liu , Liu Yang
Journal of Central South University ›› 2014, Vol. 21 ›› Issue (5) : 1935 -1945.
Automated pattern-directed refactoring for complex conditional statements
Complex conditional statement is one of the bad code smells, which affects the quality of the code and design of software. In the proposed approach, two commonly-used design patterns for handling complex conditional statements are selected, and they are the factory method pattern and the strategy pattern. Two pattern-directed refactoring approaches based on the two design patterns are proposed. Each approach contains a refactoring opportunities identification algorithm and an automated refactoring algorithm. After parsing the abstract syntax tree generated from source code, the refactoring opportunities are identified effectively and automatically. Then, for candidate code, refactoring algorithms are executed automatically, which are used to simplify or remove complex conditional statements. By empirical analysis and quality assessment, the code after refactoring has better maintainability and extensibility, and the proposed approach for automated pattern-directed refactoring succeeds to reduce code size and complexity of classes.
refactoring / abstract syntax tree / complex conditional statements / design patterns / factory method pattern / strategy pattern
| [1] |
|
| [2] |
|
| [3] |
|
| [4] |
|
| [5] |
|
| [6] |
|
| [7] |
|
| [8] |
|
| [9] |
|
| [10] |
|
| [11] |
|
| [12] |
|
| [13] |
|
| [14] |
|
| [15] |
|
| [16] |
|
| [17] |
|
| [18] |
|
| [19] |
|
| [20] |
KUHN T, THOMANN O. Eclipse corner article abstract syntax tree [EB/OL]. [2006-11-20]. http://www.eclipse.org/articles/Article-JavaCodeManipulationAST/index.html. |
| [21] |
Eclipse-The Eclipse Foundation open source community website. [EB/OL]. [2013-04-16]. http://www.eclipse.org/. |
/
| 〈 |
|
〉 |