基于鲸鱼优化算法的类图重构研究
2021-09-14胡志刚杨娜刘伟
胡志刚 杨娜 刘伟



摘 要:为了提高软件质量,组合使用重构技术、软件度量和元启发式搜索可以有效改进软件的结构而不影响其功能. 本文提出一种基于鲸鱼优化算法的类图重构方法,并结合耦合、继承、抽象3个指标所构建的质量模型来指导类图重构序列寻优. 在6个不同的开源程序上使用鲸鱼优化方法对类图进行重构,研究结果表明:基于鲸鱼优化算法的类图重构在质量增益上优于模拟退火算法和爬山算法,可有效提高重构质量.
关键词:软件质量;软件重构;鲸鱼优化;质量度量;类图
中图分类号:TP311 文献标志码:A
Research on Class Diagram Refactoring Based
on Whale Optimization Algorithm
HU Zhigang YANG Na LIU Wei
(1. School of Computer Science and Engineering,Central South University,Changsha 410083,China;
2. College of Computer Science and Electronic Engineering,Hunan University of Chinese Medicine,Changsha 410208,China)
Abstract:In order to improve software quality,the combination of refactoring techniques,software metrics,and meta-heuristic search can effectively improve the structure of software without affecting its function. In this paper,a class diagram refactoring method based on Whale Optimization Algorithm is proposed,and the quality model constructed by index coupling,inheritance and abstraction is empolyed to guide the search for the optimal refactoring sequence. Cetacean optimization method is used to refactor the class diagram in six different open source programs. The results show that the class diagram refactor the based on cetacean optimization algorithm is superior to Simulated Annealing Algorithm and Hill Climbing Algorithm in terms of quality gain,and can effectively improve the quality refactoring.
Key words:software quality;software refactoring;whale optimization algorithm;quality measures;class diagram
軟件产品经常随着需求的变更演变为完成不同的功能,这些演变可能使软件设计变得更加复杂,致使软件质量降低. 重构被定义为优化现有系统的内部结构而不改变其功能,主要通过改进抽象、耦合、继承等质量属性来提高软件质量. 重构最初是在面向对象软件的环境中提出的[1],软件重构已经被应用于面向方面的软件、软件产品线等不同的环境,以及应用在代码、模型、文档等不同的层次中.
软件重构阶段可以分为代码层重构和模型层重构,模型层的类图重构通过找到最佳重构序列来提高软件质量,而寻找最佳重构是一个优化问题,可通过进化算法来实现,进化算法包括爬山算法[2]、模拟退火算法、群体智能算法和生物地理算法等. 群体智能算法主要是模拟动物的群体行为,依靠相互合作来捕获食物,通……
