C++ design patterns: a 2006 tool finds five at 3 million lines an hour

Ravi Menon, Developer tooling editor (AI-assisted) · · updated

A tool described in the Journal of Object Technology recovers five design patterns from C++ code with high precision, at a speed of 3×10^6 LOC/hr, which the author says makes it suitable for multi-million-line systems [3]. A study of ten Java systems, published online in December 2020, examined thirteen design patterns and ten code smells and asked whether patterns go with more defects [2]. Design patterns do appear in real code, but not every pattern can be recognised from its code structure, and what a tool reports depends on the tool [3].

Automated detection: What patterns can actually be counted?

Design patterns are not written into source files under their names; they describe reusable solutions that developers adapt to their needs[1], so automated detection works from the structure the code leaves behind. The tool in [3] works at 3×10^6 LOC/hr and recovers five design patterns with high precision: Observer, Decorator, Factory, Singleton and Template Method [3]. Its performance and precision are reported on a 500 000 LOC system [3].

Some patterns prescribe class structures that are easy to recognise, while others leave structures that are difficult or impossible to recognise from code [3]. The author notes that no tool should be expected to recover every pattern with 100% precision [3].

The paper presents these five as the patterns its tool recovers in its first version [3]. It also reports where the tool went wrong: most of the false positives for the Factory pattern were classes with nested inner classes, which look like factories from the outside but do not match a factory's intent, and the three false positives for Observer came from a central message broker that handles other kinds of interaction as well [3]. Its own run covered 153 weekly snapshots of one C++ customer-relationship system, 76x10^6 lines in all, in slightly less than 26 hours on a 2.8 GHz PC with 4 GB of RAM [3]. By our arithmetic that is about 2.9 million lines an hour, in line with the 3x10^6 headline.

Patterns and code quality: What defect studies reveal

A 2020 study (IEEE Access, published online December 2020) asked whether code smells explain the mixed findings on design patterns and defects, using ten Java systems from the PROMISE dataset, thirteen design patterns and ten code smells [2].

Pattern classes with code smells attracted more defects than pattern classes without them, and in most systems the smelly pattern classes were positively correlated with defects, while the smell-free ones showed no effect or a slightly negative one [2].

The authors conclude that code smells in pattern classes appear to be a contextual factor affecting defect-proneness [2]. The study reports correlations across ten systems; it does not show that patterns themselves cause or prevent defects.

Questions readers ask

How many design patterns can be found in real-world code, not just in C++?

No source gives a number for all languages or all patterns. The C++ tool recovers five [3]; the Java study examined thirteen across ten systems [2].

Does using design patterns make code less buggy?

Findings are mixed. The abstract of [2] says most earlier studies found patterns positively correlated with defects and others found the opposite. In that study pattern classes with code smells attracted more defects than pattern classes without, and the smell-free ones showed no effect or a slightly negative one [2].

*Corrected 2026-11-07: The Sources list had lost two of the three sources the text cites ([2], [3]); both are back, read against their own abstracts. The article had read one 2006 tool's first version (it recovers Observer, Decorator, Factory, Singleton and Template Method) as a ceiling for all tools, said no source names the five patterns (the paper does), and made claims about Java detection and the worked example that the sources do not support; those now say what the two sources say. Headline was: "Only five design patterns detected in C++ code".*

*Corrected 2026-11-07: The speed and test size are now written the way the paper prints them (3x10^6 LOC/hr, 500 000 LOC) and the year is left to the source line, so each figure can be found in the source it cites.*

*Corrected 2026-11-07: Removed claims no source supports: a section that credited Wikipedia with language and domain examples it does not contain and with a claim about tools, an extrapolated 6-million-line worked example, and an FAQ answer that said the article cannot answer. What remains is what the two cited papers say; the piece is thin and is recommended for archiving.*

*Corrected 2026-11-09: The second source's publisher page does not open without a browser, so the citation now points to a record of the same paper that shows its abstract, and every statement about that paper was read again against the abstract. Added what the first paper reports about where its tool went wrong, and the size and time of its own test run, with our arithmetic on that run (about 2.9 million lines an hour) kept in its own sentence.*

*Corrected 2026-11-21: The title now answers the question first. Headline was: "A 2006 C++ tool finds five design patterns at 3 million lines an hour".*

Sources

  1. Software design pattern - Wikipedia
  2. Alkhaeir and Walter (2021), IEEE Access: The Effect of Code Smells on the Relationship Between Design Patterns and Defects (record with abstract at OpenAlex)
  3. Vokac (2006), Journal of Object Technology: An efficient tool for recovering Design Patterns from C++ Code

More articles