mlsanityData to 14 Oct 2026

Strategies for Guiding LLMs to Use Software Design Patterns: A Case of Singleton

arXiv 2605.26898 ↗First posted 26 May 2026cs.SE cs.AIcited by 0

Not on the map. Why?

Abstract (arXiv)

Large Language Models (LLMs) can generate functional source code from natural-language prompts, but often fail to consistently follow higher-level architectural structures or design patterns. Since LLMs are increasingly used in software engineering, their ability to apply established design principles to generated code is crucial to the long-term success of software products. Therefore, the goal of this paper is to identify strategies for guiding LLMs to incorporate design patterns into the generated source code. We designed a computational experiment to evaluate the ability of 13 LLMs to generate code that follows the Singleton design pattern, using four prompting strategies: instructions, binary automated feedback, extensive automated feedback, and extensive feedback with few-shot prompts, in 164 Java coding challenges from HumanEval-X. Our results shows that the optimal strategy to guide LLMs to include design patterns depends heavily on the type of model. Still, overall, iterative binary feedback provides the best alignment with Singleton while preserving or improving the code's functionality. With guiding with instructions, Llama 3.3 generated Singleton classes in 100% of cases and improved code functionality, increasing the number of tests passed by 34.1 percentage points. It achieved a similar result with guidance through instructions and binary feedback. Qwen 3 (8B) increased the alignment with Singleton to 99.2% and the functionality to 58.6% using binary feedback. Our result suggests that even simple strategies can be used to guide LLMs to use design patterns.

Key facts. No citing papers in the map yet (data through 14 Oct 2026). Builds on 10 of its 23 references that are in the map. First posted on arXiv 26 May 2026.

Builds on

10 of 23 references.

References · 10

  1. 2020Language Models are Few-Shot Learnerscited by 32,419
  2. 2023Reflexion: Language Agents with Verbal Reinforcement Learningcited by 4,276
  3. 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,442
  4. 2023Teaching Large Language Models to Self-Debugcited by 988
  5. 2023Language Models can Solve Computer Taskscited by 372
  6. 2024Using AI-Based Coding Assistants in Practice: State of Affairs, Perceptions, and Ways Forwardcited by 45
  7. 2024PerfCodeGen: Improving Performance of LLM Generated Code with Execution Feedbackcited by 24
  8. 2025CodeFlowBench: A Multi-turn, Iterative Benchmark for Complex Code Generationcited by 17
  9. 2025Is GPT-OSS Good? A Comprehensive Evaluation of OpenAI's Latest Open Source Modelscited by 11
  10. 2025Do Code LLMs Understand Design Patterns?cited by 9

Built on by

Not cited yet.