Design patterns describe recurring solutions to software design problems.
In this thesis, we develop a tool for detecting design patterns in C# code.
Using the Roslyn platform, the code is transformed into a graph of facts
represented as subject–predicate–object triples, which is then queried to find
candidates for all 23 Gang of Four patterns. An optional semantic stage
uses a large language model to determine whether a candidate expresses
the intent that distinguishes the pattern. The findings identify the roles of
participants in the detected pattern and their locations in the code, and can
be exported in several machine-readable formats. We evaluate the system on
40 manually labelled units from seven real-world open-source C# projects
published on GitHub. In separate correctness checks, the structural detectors
achieve a perfect result on 23 bundled and 22 external textbook examples; on
the evaluation corpus of manually labelled examples, they achieve a micro
F1 score of 0.667. When the structural candidates from the same code are
additionally verified by a large language model, the micro F1 score increases
to 0.828. The thesis presents a successful proof of concept for hybrid design
pattern detection and provides a foundation for its further development.
|