Do LLMs support generating code that is compliant with creational design patterns?

Large Language Models (LLMs) have been increasingly employed in Software Engineering; however, their reliability in applying established practices such as design patterns remains uncertain. This study investigates the ability of the LLMs ChatGPT, Gemini, and Copilot to generate code that adheres to creational design patterns. The analysis considers the correctness of the implementations, as well as the complexity and maintainability of the generated code. To this end, a comparative study was conducted involving 150 programs generated by the models and 50 reference programs developed by humans. The results reveal that, although LLMs are generally capable of applying design patterns, a critical failure rate of 22.67% was observed, with significant performance variation across models and design patterns. Regarding code complexity, no substantial differences were identified; however, in most cases, the artifacts generated by the LLMs exhibited higher maintainability than the human-written reference implementations.

Authors

Institutions

Publication Details

Published
2025-09-22
DOI
https://doi.org/10.5753/wbots.2025.15181
Primary Topic
Open Source Software Innovations
Type
article
Field-Weighted Citation Impact
0.00

Funders

Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Do LLMs support generating code that is compliant with creational design patterns?

Eduardo K. Viegas, Silvana Morita Melo, Cláudia Machado, Leo Natan Paschoal
Open Source Software Innovations
article

Do LLMs support generating code that is compliant with creational design patterns?

Eduardo K. Viegas, Silvana Morita Melo, Cláudia Machado, Leo Natan Paschoal
article en

Abstract

Large Language Models (LLMs) have been increasingly employed in Software Engineering; however, their reliability in applying established practices such as design patterns remains uncertain. This study investigates the ability of the LLMs ChatGPT, Gemini, and Copilot to generate code that adheres to creational design patterns. The analysis considers the correctness of the implementations, as well as the complexity and maintainability of the generated code. To this end, a comparative study was conducted involving 150 programs generated by the models and 50 reference programs developed by humans. The results reveal that, although LLMs are generally capable of applying design patterns, a critical failure rate of 22.67% was observed, with significant performance variation across models and design patterns. Regarding code complexity, no substantial differences were identified; however, in most cases, the artifacts generated by the LLMs exhibited higher maintainability than the human-written reference implementations.

Pontifical Catholic University of Puerto Rico (PR), Pontifícia Universidade Católica do Paraná (BR), Faculdades Guarulhos (BR), Universidad San Pedro (PE)
Conselho Nacional de Desenvolvimento Científico e Tecnológico
Openalex Percentile: Top 69%
Open Source Software Innovations
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.