Identification of refactoring opportunities for source code based on class association relationships
Wei Liu , Na Yang , Xin-di Huang , Wei Hu , Zhi-gang Hu
Journal of Central South University ›› 2021, Vol. 27 ›› Issue (12) : 3768 -3778.
Identification of refactoring opportunities for source code based on class association relationships
In order to deal with the complex association relationships between classes in an object-oriented software system, a novel approach for identifying refactoring opportunities is proposed. The approach can be used to detect complex and duplicated many-to-many association relationships in source code, and to provide guidance for further refactoring. In the approach, source code is first transformed to an abstract syntax tree from which all data members of each class are extracted, then each class is characterized in connection with a set of association classes saving its data members. Next, classes in common associations are obtained by comparing different association classes sets in integrated analysis. Finally, on condition of pre-defined thresholds, all class sets in candidate for refactoring and their common association classes are saved and exported. This approach is tested on 4 projects. The results show that the precision is over 96% when the threshold is 3, and 100% when the threshold is 4. Meanwhile, this approach has good execution efficiency as the execution time taken for a project with more than 500 classes is less than 4 s, which also indicates that it can be applied to projects of different scales to identify their refactoring opportunities effectively.
identification of refactoring opportunities / abstract syntax tree / class association relationships / common association classes / source code
| [1] |
|
| [2] |
|
| [3] |
|
| [4] |
|
| [5] |
|
| [6] |
|
| [7] |
|
| [8] |
|
| [9] |
|
| [10] |
|
| [11] |
|
| [12] |
|
| [13] |
|
| [14] |
|
| [15] |
|
| [16] |
|
| [17] |
|
| [18] |
|
| [19] |
|
| [20] |
|
| [21] |
|
| [22] |
|
| [23] |
|
| [24] |
|
| [25] |
|
| [26] |
|
| [27] |
|
| [28] |
KUHN T, GMBH E.M, THOMANN O. Abstract syntax tree [EB/OL]. [2019-10-30]. http://www.eclipse.org/articles/Article-JavaCodeManipulation_AST/index.html. |
| [29] |
|
/
| 〈 |
|
〉 |