Teaching Code Refactoring Using LLMs
Khairnar, Anshul, Rajoju, Aarya, Gehringer, Edward F.
–arXiv.org Artificial Intelligence
--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. Despite the importance of refactoring, teaching effective techniques remains challenging, particularly when students encounter real-world, complex codebases rather than contrived examples [2]. Students often struggle with identifying refactoring opportunities in unfamiliar code and implementing appropriate transformations that preserve functionality while enhancing quality. Open Source Software (OSS) projects offer an authentic environment for students to practice refactoring skills.
arXiv.org Artificial Intelligence
Aug-14-2025
- Country:
- Asia > China
- Hebei Province > Shijiazhuang (0.04)
- Atlantic Ocean > North Atlantic Ocean
- Baltic Sea (0.04)
- North America > United States
- North Carolina > Wake County > Raleigh (0.05)
- Asia > China
- Genre:
- Research Report > New Finding (1.00)
- Industry:
- Education > Curriculum > Subject-Specific Education (1.00)
- Technology: