Design pattern recognition: a study of large language models
Journal article, 2025

ContextAs Software Engineering (SE) practices evolve due to extensive increases in software size and complexity, the importance of tools to analyze and understand source code grows significantly.ObjectiveThis study aims to evaluate the abilities of Large Language Models (LLMs) in identifying DPs in source code, which can facilitate the development of better Design Pattern Recognition (DPR) tools. We compare the effectiveness of different LLMs in capturing semantic information relevant to the DPR task.MethodsWe studied Gang of Four (GoF) DPs from the P-MARt repository of curated Java projects. State-of-the-art language models, including Code2Vec, CodeBERT, CodeGPT, CodeT5, and RoBERTa, are used to generate embeddings from source code. These embeddings are then used for DPR via a k-nearest neighbors prediction. Precision, recall, and F1-score metrics are computed to evaluate performance.ResultsRoBERTa is the top performer, followed by CodeGPT and CodeBERT, which showed mean F1 Scores of 0.91, 0.79, and 0.77, respectively. The results show that LLMs without explicit pre-training can effectively store semantics and syntactic information, which can be used in building better DPR tools.ConclusionThe performance of LLMs in DPR is comparable to existing state-of-the-art methods but with less effort in identifying pattern-specific rules and pre-training. Factors influencing prediction performance in Java files/programs are analyzed. These findings can advance software engineering practices and show the importance and abilities of LLMs for effective DPR in source code.

Design pattern recognition

Software reengineering

Large language model

Deep learning

Author

Sushant Kumar Pandey

Chalmers, Computer Science and Engineering (Chalmers), Interaction Design and Software Engineering

University of Groningen

University of Gothenburg

Sivajeet Chand

Chalmers, Computer Science and Engineering (Chalmers), Interaction Design and Software Engineering

University of Gothenburg

Jennifer Horkoff

University of Gothenburg

Chalmers, Computer Science and Engineering (Chalmers), Interaction Design and Software Engineering

Miroslaw Staron

University of Gothenburg

Chalmers, Computer Science and Engineering (Chalmers), Software Engineering (Chalmers)

Miroslaw Ochodek

Poznan University of Technology

Darko Durisic

Volvo Cars

Empirical Software Engineering

1382-3256 (ISSN) 1573-7616 (eISSN)

Vol. 30 3 69

Subject Categories (SSIF 2025)

Software Engineering

Computer Sciences

DOI

10.1007/s10664-025-10625-1

Related datasets

Design-Pattern-Recognition-using-Large-Language-Models (Replication package) [dataset]

URI: https://github.com/sushantkumar007007/Design-Pattern-Recognition-using-Large-Language-Models-

More information

Latest update

3/7/2025 9