paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Are We SOLID Yet? An Empirical Study on Prompting LLMs to Detect Design Principle Violations

我们SOLID了吗?关于提示LLM检测设计原则违反的实证研究
ASE 2025 40th IEEE/ACM International Conference on Automated Software Engineering (ASE)2025匹配度 3/10 · 该论文用提示策略评测LLM检测SOLID设计原则违反,属于LLM辅助代码分析,与“AI→PL”方向有弱关联;但它核心是提示工程与LLM能力评测,不涉及静态分析/形式化验证方法、浮点或贝叶斯程序分析,也未使用当前最强模型或Agentic程序分析。引用 1 inbox
Fatih Pehlivan, Arçin Ülkü Ergüzen, Sahand Moslemi Yengejeh, Mayasah Lami, Anil Koyuncu
crossref: 2026-09-12

AI 速览

一句话:构建240例基准,系统评测四种提示策略下四个LLM检测全部五项SOLID违反的能力,揭示需按设计情境匹配模型与提示。

传统静态分析难以检测SOLID等语义设计缺陷,需理解面向对象设计模式;现有方案多局限于单一原则或单一语言。本文用定制化提示工程评估CodeLlama:70B、DeepSeekCoder:33B、Qwen2.5 Coder:32B与GPT-4o Mini四个LLM检测全部五项SOLID违反的能力,并构建含240个人工验证样例的基准数据集。作者设计四种受zero-shot、few-shot与chain-of-thought启发的提示策略,系统测量其影响。结果显示GPT-4o Mini显著领先,但在DIP等困难原则上仍显吃力;提示策略影响巨大且无普适最优(ENSEMBLE利于OCP,EXAMPLE利于DIP),准确率还受语言特性与代码复杂度显著影响。结论:AI驱动设计分析需按设计情境匹配模型与提示。

问题
语义层面的设计缺陷(如SOLID原则违反)难以被传统静态分析检测,且现有方案多只覆盖单一原则或单一语言,缺乏跨五原则、多语言代码库的检测能力。
方法
提出基于定制化提示工程的方法,在自建的240个人工验证代码样例基准上,用四种受zero-shot、few-shot与chain-of-thought启发的提示策略评测四个主流LLM。
评估
以检测准确率为指标,跨模型、跨SOLID原则、跨提示策略与跨编程语言进行系统对比,并分析代码复杂度的影响。
原文摘要(Abstract)

Traditional static analysis methods struggle to detect semantic design flaws, such as violations of the SOLID principles, which require a strong understanding of object-oriented design patterns and principles. Existing solutions typically focus on individual SOLID principles or specific programming languages, leaving a gap in the ability to detect violations across all five principles in multi-language codebases. This paper presents a new approach: a methodology that leverages tailored prompt engineering to assess LLMs on their ability to detect SOLID violations across multiple languages. We present a benchmark of four leading LLMs—CodeLlama:70B, DeepSeekCoder:33B, Qwen2.5 Coder:32B, and GPT-4o Mini—on their ability to detect violations of all five SOLID principles. For this evaluation, we construct a new benchmark dataset of 240 manually validated code examples. Using this dataset, we test four distinct prompt strategies inspired by established zero-shot, few-shot, and chain-of-thought techniques to systematically measure their impact on detection accuracy. Our emerging results reveal a stark hierarchy among models, with GPT-4o Mini decisively outperforming others, yet even it struggles with challenging principles like DIP. Crucially, we show that prompt strategy has a dramatic impact, but no single strategy is universally best; for instance, a deliberative ENSEMBLE prompt excels at OCP detection while a hint-based EXAMPLE prompt is superior for DIP violations. Across all experiments, detection accuracy is heavily influenced by language characteristics and degrades sharply with increasing code complexity. These initial findings demonstrate that effective, AI-driven design analysis requires not a single "best" model, but a tailored approach that matches the right model and prompt to the specific design context, highlighting the potential of LLMs to support maintainability through AI-assisted code analysis.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot9306,
  title = {Are We SOLID Yet? An Empirical Study on Prompting LLMs to Detect Design Principle Violations},
  author = {Fatih Pehlivan and Arçin Ülkü Ergüzen and Sahand Moslemi Yengejeh and Mayasah Lami and Anil Koyuncu},
  booktitle = {ASE},
  year = {2025},
  doi = {10.1109/ase63991.2025.00350}
}