An automatic approach to detecting and eliminating lazy classes based on abstract syntax trees
Wei Liu1, Zhigang Hu1, 2, Hongtao Liu2
1School of Information Science and Engineering, Central South University, Changsha 410083, China
2School of Software, Central South University, Changsha 410075, China
To detect and eliminate lazy classes in source code, an automatic approach based on abstract syntax trees (ASTs) is proposed. Source code files transform to ASTs at first, then the relationships between classes are extracted from the ASTs. Three common relationships are considered, which are generalization, association and dependency. Some definitions are proposed to represent the classes set of different kinds of relationships. After carrying out several set operations on these sets, the candidate lazy classes set is obtained. By further manual examination, the true lazy classes are acquired. Finally, a specific lazy class will be removed automatically from the project. Four projects are tested to detect and eliminate the lazy classes. The experimental results show that the proposed detection algorithm has high precision rate. In addition, this approach has good efficiency, and its execution time has a linear relationship to the size of a system.