Empirical Study of the Relationship between Design Patterns and Code Smells
收藏资源简介:
Software systems are often developed in such a way that good practices in the object-oriented paradigm are not met, causing the occurrence of specific disharmonies which are sometimes called code smells. Design patterns catalogue best practices for developing object-oriented software systems. Although code smells and design patterns are widely divergent, there might be a co-occurrence relation between them. The objective of this paper is to empirically evaluate if the presence of design patterns is related to the presence of code smells at different granularity levels. We performed an empirical replication study using 20 design patterns and 13 code smells in ten small-size to medium-size, open-source Java-based systems. We applied statistical analysis and association rules. Results confirm that classes participating in design patterns have less smell-proneness and smell frequency than classes not participating in design patterns. We also noticed that every design pattern category act in the same way in terms of smell-proneness in the subject systems. However, we observed, based on the association rules learning and the proposed validation technique, that some patterns may be linked with certain smells in some cases. For instance, Command patterns can co-occur with God Class, Blob and External Duplication smell. <strong>The published data set contains the following:</strong> List of the selected systems (source code files) The P-MARt: the design pattern repository as XML for the selected systems. Data of design patterns and code smells: We processed this data by parsing the design pattern XML file and running the smell detection tool (inFusion). The data of the data mining analysis.
软件开发时常未能遵循面向对象范式下的最佳实践,进而引发特定的不和谐现象,这类现象常被称为代码异味(code smells)。设计模式(Design patterns)汇总了面向对象软件开发的最佳实践规范。尽管代码异味与设计模式二者差异显著,但二者之间可能存在共现关联。本研究的目标为从实证层面评估:在不同粒度层级下,设计模式的存在是否与代码异味的存在存在相关性。我们针对10个中小型开源Java系统开展了实证复现研究,共纳入20种设计模式与13种代码异味。研究中采用了统计分析与关联规则挖掘方法。研究结果证实:参与设计模式实现的类,其代码异味易发性与异味出现频率均显著低于未参与设计模式的类。同时我们发现,在本次研究的系统中,所有设计模式类别在代码异味易发性方面表现出一致的规律。但基于关联规则学习与本文提出的验证技术,我们观察到:在部分场景下,部分设计模式可能与特定代码异味存在关联。例如,命令模式(Command patterns)可能与上帝类(God Class)、Blob以及外部重复(External Duplication)代码异味共现。本公开数据集包含如下内容:所选研究系统(含源代码文件)清单;P-MARt:面向所选系统的XML格式设计模式仓库;设计模式与代码异味相关数据:我们通过解析设计模式XML文件并运行异味检测工具inFusion完成了该数据的预处理;数据挖掘分析相关数据。



