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.

PDF
Journal of Central South University ›› 2021, Vol. 27 ›› Issue (12) : 3768 -3778. DOI: 10.1007/s11771-020-4576-7
Article

Identification of refactoring opportunities for source code based on class association relationships

Author information +
History +
PDF

Abstract

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.

Keywords

identification of refactoring opportunities / abstract syntax tree / class association relationships / common association classes / source code

Cite this article

Download citation ▾
Wei Liu, Na Yang, Xin-di Huang, Wei Hu, Zhi-gang Hu. Identification of refactoring opportunities for source code based on class association relationships. Journal of Central South University, 2021, 27(12): 3768-3778 DOI:10.1007/s11771-020-4576-7

登录浏览全文

4963

注册一个新账户 忘记密码

References

[1]

FowlerMRefactoring: Improving the design of existing code [M], 1999, Massachusetts, Addison-Wesley

[2]

KerievskyJRefactoring to patterns [M], 2004, Massachusetts, Addison-Wesley

[3]

KaurS, SinghP. How does object-oriented code refactoring influence software quality? Research landscape and challenges [J]. Journal of Systems and Software, 2019, 157: 110394

[4]

FernandesE, ChávezA, GarciaA, FerreiraI, CedrimD, SousaL, OizumiW. Refactoring effect on internal quality attributes: What haven’t they told you yet? [J]. Information and Software Technology, 2020, 126106347

[5]

MumtazH, AlshayebM, MahmoodS, NiaziM. An empirical study to improve software security through the application of code refactoring [J]. Information and Software Technology, 2018, 96112-125

[6]

TourwéT, MensT. Identifying refactoring opportunities using logic meta programming [C]. CSMR’03: Proceedings of the Seventh European Conference on Software Maintenance and Reengineering, 200391100

[7]

LiuH, NiuZ-d, MaZ-y, ShaoW-zhong. Identification of generalization refactoring opportunities [J]. Automated Software Engineering, 2013, 20(1): 81-110

[8]

HigoY, KusumotoS, InoueK. A metric-based approach to identifying refactoring opportunities for merging code clones in a Java software system [J]. Journal of Software Maintenance and Evolution: Research and Practice, 2008, 20(6): 435-461

[9]

HottaK, HigoY, KusumotoS. Identifying, tailoring, and suggesting form template method refactoring opportunities with program dependence graph [C]. CSMR’12: Proceedings of the 2012 16th European Conference on Software Maintenance and Reengineering, 20125362

[10]

DallalJ A. Constructing models for predicting extract subclass refactoring opportunities using object-oriented quality metrics [J]. Information and Software Technology, 2012, 54(10): 1125-1141

[11]

TsantalisN, ChatzigeorgiouA. Identification of move method refactoring opportunities [J]. IEEE Transactions on Software Engineering, 2009, 35(3): 347-367

[12]

TsantalisN, ChatzigeorgiouA. Identification of refactoring opportunities introducing polymorphism [J]. Journal of Systems and Software, 2010, 83(3): 391-404

[13]

TsantalisN, ChatzigeorgiouA. Identification of extract method refactoring opportunities for the decomposition of methods [J]. Journal of Systems and Software, 2011, 84(10): 1757-1782

[14]

FokaefsM, TsantalisN, StrouliaE, ChatzigeorgiouA. Identification and application of extract class refactorings in object-oriented systems [J]. Journal of Systems and Software, 2012, 85(10): 2241-2260

[15]

BavotaG, OlivetoR, De LuciaA, AntoniolG, GueheneucY G. Playing with refactoring: Identifying extract class opportunities through game theory [C]. ICSM’ 10: Proceedings of the 2010 IEEE International Conference on Software Maintenance, 201015

[16]

BavotaG, De LuciaA, OlivetoR. Identifying extract class refactoring opportunities using structural and semantic cohesion measures [J]. Journal of Systems and Software, 2011, 84(3): 397-414

[17]

KayaM, FawcettJ W. Identification of extract method refactoring opportunities through analysis of variable declarations and uses [J]. International Journal of Software Engineering and Knowledge Engineering, 2017, 27(1): 49-69

[18]

PappalardoG, TramontanaE. Suggesting extract class refactoring opportunities by measuring strength of method interactions [C]. IEEE 2013 20th Asia-Pacific Software Engineering Conference (APSEC), 2013105110

[19]

DallalJ A. Predicting move method refactoring opportunities in object-oriented code [J]. Information and Software Technology, 2017, 92: 105-120

[20]

LiuH, LiuQ-r, LiuY, WangZ-ding. Identifying renaming opportunities by expanding conducted rename refactorings [J]. IEEE Transactions on Software Engineering, 2015, 41(9): 887-900

[21]

CharalampidouS, AmpatzoglouA, ChatzigeorgiouA, GkortzisA, AvgeriouP. Identifying extract method refactoring opportunities based on functional relevance [J]. IEEE Transactions on Software Engineering, 2017, 43(10): 954-974

[22]

WangY, YuH, ZhuZ-l, ZhangW, ZhaoY-li. Automatic software refactoring via weighted clustering in method-level networks [J]. IEEE Transactions on Software Engineering, 2018, 44(3): 202-236

[23]

TerraR, ValenteM T, MirandaS, SalesV. JMove: a novel heuristic and tool to detect move method refactoring opportunities [J]. Journal of Systems and Software, 2018, 138: 19-36

[24]

GuggulothuT, MoizS A. An approach to suggest code smell order for refactoring [M]. Emerging Technologies in Computer Engineering: Microservices in Big Data Analytics, 2019, Singapore, Springer Singapore, 250260

[25]

YoshidaN, NumataS, ChoizE, InoueK. Proactive clone recommendation system for extract method refactoring [C]. 2019 IEEE/ACM 3rd International Workshop on Refactoring (IWoR), 20196770

[26]

NyamaweA S, LiuH, NiuZ-d, WangW-t, NiuNan. Recommending refactoring solutions based on traceability and code metrics [J]. IEEE Access, 2018, 6: 49460-49475

[27]

SheneamerA M. An automatic advisor for refactoring software clones based on machine learning [J]. IEEE Access, 2020, 8: 124978-124988

[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]

GammaE, HelmR, JohnsonR, VlissidesJ. Design patterns: abstraction and reuse of object-oriented design [M]. Software Pioneers, 2002, Berlin, Heidelberg, Springer Berlin Heidelberg, 701717

AI Summary AI Mindmap
PDF

126

Accesses

0

Citation

Detail

Sections
Recommended

AI思维导图

/