Abstract

The relationship between design patterns and defects was investigated in the literature, but with mixed results. While the majority of studies found the presence of patterns to be positively correlated with defects, other works reported the opposite conclusions. This may suggest that contextual factors affect this relationship. In this study we analyze the role of code smells as a confounding variable in the relationship between design patterns and defects in Java classes. To investigate this, we applied statistical tests to capture the difference in the impact on defects between pattern classes with/without code smells in 10 Java systems from the PROMISE dataset, with respect to 13 design patterns and 10 code smells. The presence of code smells in patterns appears to be a valid factor affecting defect-proneness. Pattern classes with smells attract more defects than non-smelly pattern classes, and in most systems smelly design patterns are positively correlated with the presence of defects, while non-smelly patterns tend to have no impact, or a slightly negative impact on the presence of defects. As a result, the presence of code smells in design pattern classes appears to be a contextual factor affecting the defect-proneness of the subject code.

Highlights

  • Design patterns are generic object-oriented solutions to frequently occurring design problems

  • DESIGN PATTERNS AND CODE SMELLS In our previous study [53], we investigated the relationship between design patterns and code smells at a class level and the results indicated that pattern classes are less frequently affected by smells

  • The findings suggest that pattern classes are associated with more defects than non-pattern classes, and that smells could be considered as a contextual factor in this relationship since smelly pattern classes attract more defects than both non-smelly pattern and non-pattern classes

Read more

Summary

Introduction

Design patterns are generic object-oriented solutions to frequently occurring design problems. Several other studies were inconclusive or attributed the observed effects to the nature of the patterns, to the way they are used, or to other contextual factors [6], [39]. Those findings conjecture that the relationship between design patterns and code quality attributes is not direct, but they suggest that various contextual factors may have played an important role in this relationship.

Results
Discussion
Conclusion
Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call