Large Language Models (LLMs), like ChatGPT, have gained widespread popularity and usage in various software engineering tasks, including refactoring, testing, code review, and program comprehension. Despite recent studies delving into refactoring documentation in commit messages, issues, and code review, little is known about how developers articulate their refactoring needs when interacting with ChatGPT. In this paper, our goal is to explore conversations between developers and ChatGPT related to refactoring to better understand how developers identify areas for improvement in code and how ChatGPT addresses developers' needs. Our approach relies on text mining refactoring-related conversations from 17,913 ChatGPT prompts and responses, and investigating developers' explicit refactoring intention. Our results reveal that (1) developer-ChatGPT conversations commonly involve generic and specific terms/phrases; (2) developers often make generic refactoring requests, while ChatGPT typically includes the refactoring intention; and (3) various learning settings when prompting ChatGPT in the context of refactoring. We envision that our findings contribute to a broader understanding of the collaboration between developers and AI models, in the context of code refactoring, with implications for model improvement, tool development, and best practices in software engineering.
翻译:大型语言模型(LLMs,如ChatGPT)已在各类软件工程任务中广泛应用,包括代码重构、测试、代码审查和程序理解。尽管近期研究已深入探讨提交信息、问题报告及代码审查中的重构记录,但关于开发者与ChatGPT交互时如何表达重构需求知之甚少。本文旨在探索开发者与ChatGPT之间涉及重构的对话,以更深入地理解开发者如何识别代码改进空间,以及ChatGPT如何满足开发者需求。我们通过文本挖掘方法,从17,913组ChatGPT提示与响应中提取重构相关对话,并分析开发者明确表达的重构意图。研究结果表明:(1)开发者与ChatGPT的对话中普遍存在通用性术语与特定性术语/短语;(2)开发者常提出泛化重构请求,而ChatGPT的响应通常会包含具体重构意图;(3)在重构情境下使用ChatGPT提示时存在多种学习模式。我们预期,本研究成果将有助于更广泛地理解代码重构场景中开发者与AI模型的协作机制,并为模型优化、工具开发及软件工程最佳实践提供启示。