计算机科学 ›› 2025, Vol. 52 ›› Issue (12): 32-39.doi: 10.11896/jsjkx.241200007
厉剑豪, 白瑶瑶, 密杰, 张迎周, 曹文龙, 王栋, 王刚
LI Jianhao, BAI Yaoyao, MI Jie, ZHANG Yingzhou, CAO Wenlong, WANG Dong, WANG Gang
摘要: 代码依恋现象的存在会影响系统的稳定性和可维护性。目前的代码依恋检测方法均未考虑对象类型的敏感性,导致检测精度较低。为解决此问题,提出一种基于高阶函数的过程间代码依恋检测方法。该方法根据预定义的代码依恋度量规则,将过程内带参数的局部性引用比的计算过程抽象为可复用的高阶函数式摘要;过程间检测时,在方法调用点处取出目标方法的高阶代码依恋检测摘要,并根据形实参对应关系将形参的实际类型代入摘要中,计算得到最终的局部性引用比集合,基于该集合来检测代码依恋现象以及对应的依恋集。整合了部分Java项目作为基准测试集,选取IntelliJDeodorant和IDE Inspection工具进行对比实验,结果表明:提出的方法在检测依恋实例的精度上较IDE Inspection提高了16.6%,比IntelliJDeodorant提高了1.3倍;在检测依恋集的精度上较IDE Inspection提高了37.2%,比IntelliJDeodorant提高了1.6倍。
中图分类号:
| [1]FOWLER M,BECK K,BRANT J,et al.Refactoring:improving the design of existing code [M].Massachusetts:Addison-Wesley,1999. [2]TAN T,MA X X,XU C,et al.Overview of Java Pointer Analysis[J].Journal of Computer Research and Development,2023,60(2):274-293. [3]HU Z,HUGHES J,WANG M.How functional programming mattered[J].National Science Review,2015,2(3):349-370. [4]ZHANG Y Z,ZHANG W F.Haskell:A Modern Purely Functional Programming Language[J].Journal of Nanjing University of Posts and Telecommunications(Natural Science),2007(4):13-18,23. [5]FOKAEFS M,TSANTAILS N,CHATZIGEORGIOU A.JDe-odorant:Identication and Removal of Feature Envy Bad Smells[C]//Proceedings of the 23rd IEEE International Conference on Software Maintenance.IEEE,2007:519-520. [6]SALES V,TERRA R,MIRANDA L F,et al.Recommending Move MethodRefactorings Using Dependency Sets[C]//Proceedings of the 20th Working Conference on Reverse Engineering.IEEE,2013:232-241. [7]LIU D D,ZHAO F Y.Research on feature envy detection and refactoring[J].Electronic Science and Technology,2016,29(11):70-73. [8]CHEN W K,LIU C H,LI B H.A feature envy detection method based on dataflow analysis[C]//IEEE 42nd Annual Computer Software and Applications Conference.IEEE,2018:14-19. [9]SKIPINA M,SLIVKA J,LUBURIC N,et al.Automaticdetection of Feature Envy and Data Class code smells using machine learning[J].Expert Systems With Applications,2024,243:122855. [10]PRIYAMBADHA B,KATAYAMA T,KITA Y,et al.Detection of Blob and Feature Envy Smells in a Class Diagram using Class’s Features[J].Journal of Robotics,Networking and Artificial Life,2022,9(1):43-48. [11]LIU B,LIU H,LI G J,et al.Deep Learning Based Feature Envy Detection Boosted by Real-World Examples[C]//Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering.ACM,2023:908-920. [12]AL-FRAIHAT D,SHARRAB Y,AL-GHUWAIRI A R,et al.Detecting and resolving feature envy throughautomatedmachine learning and move method refactoring[J].International Journal of Electrical & Computer Engineering,2024,4(2):2330-2343. [13]YU D J,XU Y H,WENG L H,et al.Efficient feature envy detection and refactoring based ongraphneural network[J].Automated Software Engineering,2025,32(1). [14]GRUJIC K G,PROKIC S,KOVACEVIC A,et al.MachineLearning Approaches for Code Smell Detection:A Systematic Literature Review[J/OL].Social Science Research Network,2022.https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4299859. [15]LEWOWSKI T,MADEYSKI L.Code smells detection using artificial intelligence techniques:A business-driven systematic review[M]//Studies in Systems,Decision and Control.2021:285-319. [16]BLOCH J.Effective Java[M].Beijing:Posts & Telecom Press,2024. |
|
||