基于传统机器学习的内部Getter或Setter方法异味检测

A DETECTION APPROACH FOR INTERNAL GETTER OR SETTER SMELL BASED ON TRADITIONAL MACHINE LEARNING

  • 摘要: 内部Getter或Setter方法是一种Android特有代码异味,对Android应用程序的性能及能耗均有负面影响。为检测该味道,提出一种基于传统机器学习的检测方法。首先使用程序文本信息作为特征集,然后使用5种传统机器学习模型进行检测。其中,为了去除特征集中的无关特征,提出一种特征筛选算法LGM_SU,以提高模型检测准确率。此外,为了自动获取传统有监督机器学习模型所需的大量标签数据,提出一种基于Android项目构造正负样本的方法,并实现工具ASSD。最后进行实验验证。结果表明,本文方法优于现有基于程序静态分析的检测方法,F1值提高了16.9%。此外,不同的传统机器学习算法对Android特有代码异味和对面向对象代码异味的检测效果存在差异。

     

    Abstract: Internal getter or setter method is a type of Android-specific code smell. It decreases the performance and increases the energy consumption of Android applications. In this paper, a detection method based on traditional machine learning is proposed to identify this type of code smell. Program text information was used as the feature set for smell detection purpose, and five traditional machine learning models were used to identify this type of smell. A new feature selection algorithm called LGM_SU was provided to improve the detection accuracy by removing the irrelevant features. In addition, to provide the massive labeled data required for the traditional machine learning models automatically, an approach was proposed to construct positive and negative samples based on Android projects, and ASSD tool was realized. The proposed approach was evaluated on real-world Android datasets. The results show that the proposed approach outperforms the current methods based on program static analysis, especially the F1 value was greatly improved by 16.9%. In addition, the detection effects are different on Android-specific smells and object-oriented smells by traditional machine learning algorithms.

     

/

返回文章
返回