用大模型实时指导学生重构代码,提升软件工程教学效果。
Teaching Code Refactoring Using LLMs
- 用结构化提示词让大模型识别代码异味并提出重构建议。
- 在真实开源项目中实施,学生反馈积极,代码可维护性有望提升。
- 适合软件工程教学、编程课程改革及教师设计实践作业参考。
本论文探索如何利用大语言模型(LLMs)在软件工程课程中通过实时、上下文感知的反馈,提升代码重构的教学效果。重构虽能改善代码质量,但因复杂真实代码库的存在而难以教授,传统方法如代码审查和静态分析工具提供的反馈有限且不一致。本研究将基于LLM的重构辅助融入课程项目,采用结构化提示词帮助学生识别并解决长方法、低内聚等代码异味。该干预措施于2025年春季在持续维护的开源项目中实施,通过学生反馈及计划中的代码质量分析进行评估。结果表明,大模型有助于弥合理论与实践的差距,支持学生深入理解可维护性与重构原则。
原文摘要 · Abstract (English)
This Innovative Practice full paper explores how Large Language Models (LLMs) can enhance the teaching of code refactoring in software engineering courses through real-time, context-aware feedback. Refactoring improves code quality but is difficult to teach, especially with complex, real-world codebases. Traditional methods like code reviews and static analysis tools offer limited, inconsistent feedback. Our approach integrates LLM-assisted refactoring into a course project using structured prompts to help students identify and address code smells such as long methods and low cohesion. Implemented in Spring 2025 in a long-lived OSS project, the intervention is evaluated through student feedback and planned analysis of code quality improvements. Findings suggest that LLMs can bridge theoretical and practical learning, supporting a deeper understanding of maintainability and refactoring principles.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。