arXiv:2502.18458cs.SEcs.LG2025-02中稿 · PATTERNS 2025被引 4

用大模型自动识别代码中的设计模式实例,提升代码可维护性。

LLM-Based Design Pattern Detection

  • 利用大模型分析类在模式中的角色,定位设计模式实例。
  • 能处理真实代码中复杂多变且无显式标注的模式实现。
  • 适合需要重构、维护或学习最佳实践的开发者使用。

在陌生代码库中检测设计模式实例仍然是一个具有挑战性但至关重要的任务,有助于提升软件质量和可维护性。传统静态分析工具常因真实代码中复杂的结构、多样的表现形式以及缺乏显式注解而难以有效识别。本文提出一种新方法,借助大语言模型(LLM)自动识别跨多种代码库的设计模式实例。该方法聚焦于识别类在模式实例中的角色,提供对软件结构与意图更清晰的理解,旨在支持开发者、提升代码理解效率,并简化重构、维护及遵循最佳实践等任务。

原文摘要 · Abstract (English)

Detecting design pattern instances in unfamiliar codebases remains a challenging yet essential task for improving software quality and maintainability. Traditional static analysis tools often struggle with the complexity, variability, and lack of explicit annotations that characterize real-world pattern implementations. In this paper, we present a novel approach leveraging Large Language Models to automatically identify design pattern instances across diverse codebases. Our method focuses on recognizing the roles classes play within the pattern instances. By providing clearer insights into software structure and intent, this research aims to support developers, improve comprehension, and streamline tasks such as refactoring, maintenance, and adherence to best practices.

代码分析大模型设计模式

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。