Detecting instances of design patterns helps assessing the quality of
the source code of object-oriented software systems. The DPF (Design
Pattern Finder) tool automatically extracts used design patterns from
the object oriented source code. DPF is based on a meta-model and
graph comparison techniques. Similar to other automatic design pattern
extraction techniques, the results computed by DPF are not always very
precise: some design patterns might be missed (DPF is not complete),
and some design patterns might be falsely detected (DPF is not sound).
This case study tackles the latter, using model checking to refine the
results computed by DPF.

To extract design patterns from a Java system, the proposed approach
applies the following steps. First DPF analyzes the source and byte
code, yielding a model (called system graph) according to DPF's
meta-model. Second, design pattern candidates are extracted from the
system graph using graph matching. Third, the system graph is
translated into a basic LOTOS specification, and each design pattern
candidate is translated into a set of mu-calculus formulae,
instantiating formula templates with parameters extracted during the
model construction step. Finally, the obtained mu-calculus formulae
are checked on the LOTOS specification: if a formula is not satisfied,
the corresponding design pattern is a false positive, i.e., wrongly
detected.

Conclusions:

Using model checking takes into account additional structural or
behavioral relationships, enabling to check a wider set of properties,
to increase the precision, and to significantly reduce the number of
false positives.