计算机科学 ›› 2021, Vol. 48 ›› Issue (12): 59-66.doi: 10.11896/jsjkx.210100077
王继文, 吴毅坚, 彭鑫
WANG Ji-wen, WU Yi-jian, PENG Xin
摘要: 随着软件开发迭代速度的加快,开发人员在编码过程中往往由于交付压力等种种原因违反软件设计的基本原则,造成代码坏味,进而影响软件质量。上帝类是最常见的代码坏味之一,指承担了太多职责的类。上帝类违反“高内聚、低耦合”的设计原则,损害软件系统的质量,会影响代码的可理解性和可维护性。因此,文中提出一种新的上帝类检测方法。首先抽取实际项目中方法在演化、语义等维度上的特征;然后对演化、语义特征进行融合,并基于融合后的结果重新聚类,将彼此关系紧密的方法重新划归到新的类簇中;通过分析实际项目中各个类的成员方法在新的聚类结果中的分布情况,计算类的内聚度,从而找出内聚度低的类作为上帝类检测结果。实验表明,所提方法优于目前主流的上帝类检测方法。与基于度量的传统检测方法相比,该方法在查全率、查准率上均提升超过20个百分点;与基于机器学习的检测方法相比,该方法尽管查全率略低,但查准率、F1值均有显著提升。
中图分类号:
[1]FOWLER M.Refactoring:improving the design of existing code[M].Addison-Wesley Longman Publishing Co.Inc.,1999. [2]CHATZIGEORGIOU A,MANAKOS A.Investigating the evolution of Code Smells in object-oriented systems[J].Innovations in Systems and Software Engineering,2014,10(1):3-18. [3]HAMZA H,COUNSELL S,HALL T,et al.Code Smell eradication and associated refactoring[M].World Scientific and Engineering Academy and Society(WSEAS),2008. [4]LANZA M,MARINESCU R,DUCASSE S.Object-oriented Metrics in Practice:Using Software Metrics to Characterize,Evaluate,and Improve the Design of Object-oriented Systems[M].Berlin:Springer-Verlag,2006. [5]FOWLER M.Trans.Refactoring:Improving the Design of Existing Code(2nd ed)[M].Beijing:Posts and Telecom Press,2015. [6]LE Q,MIKOLOV T.Distributed representations of sentences and documents[C]//International Conference on Machine Learning.PMLR,2014:1188-1196. [7]HINTON G E,SALAKHUTDINOV R R.Reducing the dimensionality of data with neural networks[J].Science,2006,313:504-507. [8]JAINA K.Data clustering:50 years beyond K-means[J].Pattern Recognition Letters,2010,31(8):651-666. [9]ETZKORN L H,GHOLSTON S E,FORTUNE J L,et al.A comparison of cohesion metrics for object-oriented systems[J].Information & Software Technology,2004,46(10):677-687. [10]PALOMBA F,NUCCI D D,TUFANO M,et al.Landfill:An Open Dataset of Code Smells with Public Evaluation[C]//Mi-ning Software Repositories.IEEE,2015:482-485. [11]TSANTALIS N,CHATZIGEORGIOU A.Identification of Extract Method Refactoring Opportunities[C]//European Confe-rence on Software Maintenance and Reengineering.IEEE Computer Society,2009:119-128. [12]REDDY K R,RAO A A.Dependency oriented complexity me- trics to detect rippling related design defects[J].ACM Sigsoft Software Engineering Notes,2009,34(4):1-7. [13]PALOMBA F,BAVOTA G,PENTA M D,et al.Detecting bad smells in source code using change history information[C]//International Conference on Automated Software Engineering.ACM,2013:268-278. [14]KHOMH F,VAUCHER S,GUEHENEUC Y,et al.BDTEX:A GQM-based Bayesian approach for the detection of antipatterns[J].J.Syst.Softw.,2011,84(4):559-572. [15]FONTANA F A,ZANONI M,MARINO A,et al.Code smell detection:Towards a machine learning-based approach[C]//2013 IEEE International Conference on Software Maintenance.IEEE,2013:396-399. [16]BU Y F,LIU H,LI G J.A God class detection method based on deep learning[J].Journal of Software,2019,30(5):161-176. [17]ZHANG X F,ZHU C.Empirical study of code smell impact on software evolution[J].Journal of Software,2019,30(5):1422-1437. [18]WU J,HOLT R,HASSAN A.Exploring software evolution using spectrographs[C]//Proceeding of the 11th Working Conference on Reverse Engineering.IEEE Press,2004:80-89. [19]WU J,SPITZER C W,HASSAN A E,et al.Evolution spectrographs:Visualizing punctuated change in software evolution[C]//Proceeding of the 7th International Workshop on Principles of Software Evolution.ACM Press,2004:57-66. [20]GALL H,JAZAYERI M,RIVA C.Visualizing software release histories:The use of color and third dimension[C]//Proceeding of the International Conference on Software Maintenance.IEEE Press,1999:99-108. [21]LANZA M.The evolution matrix:Recovering software evolu- tion using software visualization techniques[C]//Proceeding of the 1st Workshop on Principles of Software Evolution.New York:ACM Press,2001:37-42. [22]GÎRBA T,DUCASSE S.Modeling history to analyze software evolution[J].Journal of Software Maintenance and Evolution:Research and Practice,2006,18(3):207-236. [23]ROBBES R,LANZA M.A change-based approach to software evolution[J].Electronic Notes in Theoretical Computer Science,2007,166:93-109. [24]KOUROSHFAR E.Studying the effect of co-change dispersion on software quality[C]//International Conference on Software Engineering,2013:1450-1452. [25]GUO X,XIANG Y,CHEN Q,et al.LDA-based online topic detection using tensor factorization[J].J. Inf. Sci.,2013,39(4):459-469. [26]DEY A,JENAMANI M,THAKKAR J J.Lexical TF-IDF:An n-gram feature space for cross-domain classification of sentiment reviews[C]//International Conference on Pattern Recognition and Machine Intelligence.Cham:Springer,2017:380-386. [27]MIKOLOV T,CHEN K,CORRADO G,et al.Efficient estimation of word representations in vector space[J].arXiv:1301.3781,2013. [28]MIKOLOV T,SUTSKEVER I,CHEN K,et al.Distributed representations of words and phrases and their compositionality[C]//Advances in Neural Information Processing Systems.2013:3111-3119. [29]LAHITANI A R,PERMANASARI A E,SETIAWAN N A. Cosine similarity to determine similarity measure:Study case in online essay assessment[C]//2016 4th International Conference on Cyber and IT Service Management.IEEE,2016:1-6. [30]PALOMBA F,BAVOTA G,PENTA M,et al.On the diffuseness and the impact on maintainability of code smells:a large scale empirical investigation[J].Empir Software Eng.,2018,23:1188-1221. [31]FOKAEFS M,TSANTALIS N,STROULIA E,et al.JDeodo- rant:identification and application of extract class refactorings[C]//2011 33rd International Conference on Software Enginee-ring(ICSE).IEEE,2011:1037-1039. |
[1] | 张久杰, 陈超, 聂宏轩, 夏玉芹, 张丽萍, 马占飞. 基于类粒度的克隆代码群稳定性实证研究 Empirical Study on Stability of Clone Code Sets Based on Class Granularity 计算机科学, 2021, 48(5): 75-85. https://doi.org/10.11896/jsjkx.200900062 |
[2] | 何鹏, 喻绿君. 面向群体协作开发的开源软件峭壁分析 Analysis of Open Source Software Cliff Walls for Group Collaborative Development 计算机科学, 2020, 47(6): 51-58. https://doi.org/10.11896/jsjkx.190300140 |
[3] | 张静宣, 江贺. 代码标识符归一化研究现状及发展趋势 Research Status and Development Trend of Identifier Normalization 计算机科学, 2020, 47(3): 1-4. https://doi.org/10.11896/jsjkx.200200009 |
[4] | 钟林辉, 扶丽娟, 叶海涛, 齐杰, 徐静. 软件演化历史的逆向工程生成方法研究 Study on Reverse Engineering Generation Method of Software Evolution History 计算机科学, 2020, 47(11A): 549-556. https://doi.org/10.11896/jsjkx.200200067 |
[5] | 潘浩, 郑巍, 张紫枫, 芦超群. 软件网络分形结构特征研究 Study on Fractal Features of Software Networks 计算机科学, 2019, 46(2): 166-170. https://doi.org/10.11896/j.issn.1002-137X.2019.02.026 |
[6] | 唐倩文, 陈良育. 基于复杂网络理论的Java开源系统演化分析 Analysis of Java Open Source System Evolution Based on Complex Network Theory 计算机科学, 2018, 45(8): 166-173. https://doi.org/10.11896/j.issn.1002-137X.2018.08.030 |
[7] | 郁湧,康庆怡,陈长赓,阚世林,骆永军. 基于内聚度和耦合度的二分K均值方法 Bisecting K-means Clustering Method Based on Cohesion and Coupling 计算机科学, 2018, 45(6A): 460-464. |
[8] | 刘丽倩, 董东. 基于代价敏感集成分类器的长方法检测 Long Method Detection Based on Cost-sensitive Integrated Classifier 计算机科学, 2018, 45(11A): 497-500. |
[9] | 郑交交, 李彤, 林英, 谢仲文, 王晓芳, 成蕾, 刘妙. 构件系统演化一致性的判定方法 Judgement Method of Evolution Consistency of Component System 计算机科学, 2018, 45(10): 189-195. https://doi.org/10.11896/j.issn.1002-137X.2018.10.035 |
[10] | 赵会群,黄榆涵. 软件模型代数性质的程序化验证 Program Verification of Software Model’s Algebraic Properties 计算机科学, 2017, 44(11): 240-245. https://doi.org/10.11896/j.issn.1002-137X.2017.11.036 |
[11] | 钟林辉,李俊杰,夏鲸,薛良波. 基于多维属性的构件化软件演化相似性度量方法研究 Research on Evolution Similarity Measurement of Component-based Software Based on Multi-dimensional Evolution Properties 计算机科学, 2016, 43(Z11): 499-505. https://doi.org/10.11896/j.issn.1002-137X.2016.11A.112 |
[12] | 钱晔,李彤,郁涌,孙吉红,于倩,彭琳. 一种面向同步交互的软件演化过程建模方法 Approach to Modeling Software Evolution Process for Synchronous Interaction 计算机科学, 2016, 43(8): 154-158. https://doi.org/10.11896/j.issn.1002-137X.2016.08.032 |
[13] | 韩俊明,王炜. 基于LDA的软件演化确认建模 Method of Modeling Software Evolution Confirmation Based on LDA 计算机科学, 2015, 42(Z11): 464-466. |
[14] | 刘阳,刘秋荣,刘辉. 函数抽取重构的自动检测方法 Automated Detection of Extract Method Refactorings 计算机科学, 2015, 42(12): 105-107. |
[15] | 于涵,王海,彭鑫,赵文耘. 基于3D动画的软件演化信息可视化 Software Evolution Visualization Based on 3D Animation 计算机科学, 2015, 42(12): 36-39. |
|