We investigated ChatGPT's potential as a tool to help developers with code reworking in this study. Our empirical investigation, which made use of the DevGPT dataset, provided information about the circumstances in which developers can use ChatGPT most efficiently. We categorized and evaluated developer prompts to find prompt formats and content consistently producing good refactoring results.
According to the study, ChatGPT can help engineers with a range of refactoring activities, showing that it can improve code quality and efficiency. However, the prompt's precision and clarity significantly impacted ChatGPT's effectiveness. It is important to emphasize that developers who emphasize rapid formulation receive more accurate and helpful responses from users when they provide clear instructions and a rich context.Â
For research question one, how helpful is the code generated by ChatGPT in assisting developers with refactoring tasks, according to research, ChatGPT is a helpful resource for developers working on refactoring projects because it offers helpful and efficient code recommendations. A large percentage of the code produced by ChatGPT was either combined exactly or with only slight changes, indicating its usefulness in practical applications. The tool was particularly good at offering simple code enhancements and changes, which developers could easily include into their projects. Nevertheless, developers had to make extra modifications for more complicated refactoring activities, indicating that although ChatGPT is useful, it works best when utilized as a supplement rather than a stand-alone solution.
For research question two, what is the best way to prompt ChatGPT to get a satisfactory response about refactoring with the fewest possible interactions, according to the research, the most successful prompts are those that give ChatGPT precise instructions right away. Developers received more accurate and helpful responses with fewer engagements when they included code snippets, background information, and explicit task requirements in their initial prompts. Particularly successful prompts that requested ChatGPT to "act as" a different software program made expressly to help with coding produced faster and more satisfactory results.
For research question three, with which programming language does ChatGPT give the most satisfactory responses about refactoring, It was discovered that ChatGPT was most successful in providing good refactoring solutions for CSS. Developers utilized ChatGPT a lot for refactoring jobs involving CSS, and a high percentage of exact merges indicated meaningful and accurate advice. On the other hand, ChatGPT's performance varied for less popular and more difficult languages, and the resulting code was clearly altered. This shows that ChatGPT needs additional fine-tuning to support a wider range of programming languages more successfully, even while it works incredibly well for some.
In summary, ChatGPT exhibits potential as a useful tool for developers, especially for work involving well-defined refactoring. To optimize the advantages of utilizing ChatGPT in software development workflows, future research should concentrate on improving prompt techniques and investigating language-specific performance.