Defect Frequency and Design Patterns: An Empirical Study of Industrial Code

Author(s): Marek Vokac
Venue: IEEE Transactions on Software Enineering, Vol. 30, No. 12
Date: December 2004

Type of Experiement: Case Study


Number of Projects: 1
Type of Projects: commercial
Language: C++
Size of Projects: large (500,000 LOC)
Nubmer of Classes: 2047
Independent Variables: class participation in a pattern, size, in which design patter class participates
Dependent Variables: number of defects found
Design Patterns Analyzed: Observer, Factory, Decorator, Singleton, Template Method

Threats to validity
Internal: automated tool for detection of patterns
External: using the tool in other code, and different pattern usage in other software projects
Software Domain: Customer Relationship Managment

In this case study one very large commercial product is analyzed, for changes that happened to it during a period of 3 years. Software defects are extracted using the reports in the bug tracking system. and are matched with changes that happened in regular classes and in classes that were part of design patterns. The authors developed a special tool to identify design patterns in C++ code, which performed sufficiently. The study aims to identify any relationship between design patterns and the number of bugs reported in the system over time.

Data gathered indicates that the rate of defects did not change throughout the whole system during the 3 years of changes. Deocrator and Singleton patterns did not show any correlation of having more defects than any other classes. Factory pattern is also not likely to introduce significant bugs, since statistical analysis had shown the significance of the results to be very low. Since the Template Method is applied in different contexts in the code and is likely candidate for faults, however analysis shows it slightly tends to reduce faults. No significant result one way or the other is show for the Singleton pattern, even though its most likely to be misused in a global context.