重构是软件系统不断演化的关键之一,也是一项复杂而又困难的活动。传统的定位重构代码方法依赖开发者的观察和主观意识,耗时耗力,尤其在重构代码较多时。因此,提出了一套自动化定位重构的方法。该方法利用基于面向对象软件度量指标获取代码特征信息,使用相关性检验查验特征信息数据,应用主成分分析压缩和解释特征信息,应用聚类分析分类相似代码段,迅速准确定位重构。一个简单的实例表明该方法是简单有效的,并且优于传统方法。
Refactoring is one key issue during the software evolution, and is a complex and difficult task. The traditional method of locating refactorings mostly relies on observations and subjective perceptions, which is time consuming and effort wasting, especially when the number of codes needing refactoring is very large. Therefore an automatic method of locating refactorings is proposed. Using object-oriented metrics to collect the feature information of codes, using correlation test to check the feature information data, applying principle component analysis to compress and explain the feature information, applying cluster analysis to classify similar code segment, it located refactorings quickly and accurately. A simple case demonstrates that the method is simple and efficient, and outperforms the conventional method.