Skip to main navigation Skip to search Skip to main content

ChatGPT for Code Refactoring: Analyzing Topics, Interaction, and Effective Prompts

  • Eman Abdullah Alomar
  • , Luo Xu
  • , Sofia Martinez
  • , Anthony Peruma
  • , Mohamed Wiem Mkaouer
  • , Christian D. Newman
  • , Ali Ouni

Research output: Contribution to Book/Report typesContribution to conference proceedingspeer-review

1 Citation (Scopus)

Abstract

Large Language Models (LLMs), such as ChatGPT, have become widely popular and widely used in various software engineering tasks such as refactoring, testing, code review, and program comprehension. Although recent studies have examined the effectiveness of LLMs in recommending and suggesting refactoring, there is a limited understanding of how developers express their refactoring needs when interacting with ChatGPT. In this paper, our goal is to explore interactions related to refactoring between developers and ChatGPT to better understand how developers identify areas for improvement in code, and how ChatGPT addresses developers' needs. Our approach involves text mining 715 refactoring-related interactions from 29,778 ChatGPT prompts and responses, as well as the analysis of developers' explicit refactoring intentions. Our results reveal that (1) refactoring interactions between developers and ChatGPT encompass 25 themes including 'Quality', 'Objective', 'Testing', and 'Design', (2) ChatGPT's use of affirmation phrases such as 'certainly' regarding refactoring decisions, and apology phrases such as 'apologize' when resolving refactoring challenges, and (3) our refactoring prompt template enables developers to obtain concise, accurate, and satisfactory responses with minimal interactions. We envision our results enhancing researchers and practitioners understanding of how developers interact with LLMs during code refactoring.

Original languageEnglish
Title of host publicationProceedings - 2025 IEEE International Conference on Collaborative Advances in Software and Computing, CASCON 2025
EditorsHausi A. Muller, Ying Zou, Jeremy Bradbury, Eleni Stroulia
PublisherInstitute of Electrical and Electronics Engineers Inc.
Pages389-398
Number of pages10
ISBN (Electronic)9798331599485
DOIs
Publication statusPublished - 2025
Externally publishedYes
Event35th IEEE International Conference on Collaborative Advances in Software and Computing, CASCON 2025 - Toronto, Canada
Duration: 10 Nov 202513 Nov 2025

Publication series

NameProceedings - 2025 IEEE International Conference on Collaborative Advances in Software and Computing, CASCON 2025

Conference

Conference35th IEEE International Conference on Collaborative Advances in Software and Computing, CASCON 2025
Country/TerritoryCanada
CityToronto
Period10/11/2513/11/25

Fingerprint

Dive into the research topics of 'ChatGPT for Code Refactoring: Analyzing Topics, Interaction, and Effective Prompts'. These topics are generated from the title and abstract of the publication. Together, they form a unique fingerprint.

Cite this