Academic Journal

Refactoring Loops in the Era of LLMs: A Comprehensive Study.

Λεπτομέρειες βιβλιογραφικής εγγραφής
Τίτλος: Refactoring Loops in the Era of LLMs: A Comprehensive Study.
Συγγραφείς: Midolo, Alessandro, Tramontana, Emiliano
Πηγή: Future Internet; Sep2025, Vol. 17 Issue 9, p418, 27p
Θεματικοί όροι: ChatGPT, Generative artificial intelligence, Software engineering, Software refactoring, Functional programming (Computer science), Java programming language
Περίληψη: Java 8 brought functional programming to the Java language and library, enabling more expressive and concise code to replace loops by using streams. Despite such advantages, for-loops remain prevalent in current codebases as the transition to the functional paradigm requires a significant shift in the developer mindset. Traditional approaches for assisting refactoring loops into streams check a set of strict preconditions to ensure correct transformation, hence limiting their applicability. Conversely, generative artificial intelligence (AI), particularly ChatGPT, is a promising tool for automating software engineering tasks, including refactoring. While prior studies examined ChatGPT's assistance in various development contexts, none have specifically investigated its ability to refactor for-loops into streams. This paper addresses such a gap by evaluating ChatGPT's effectiveness in transforming loops into streams. We analyzed 2132 loops extracted from four open-source GitHub repositories and classified them according to traditional refactoring templates and preconditions. We then tasked ChatGPT with the refactoring of such loops and evaluated the correctness and quality of the generated code. Our findings revealed that ChatGPT could successfully refactor many more loops than traditional approaches, although it struggled with complex control flows and implicit dependencies. This study provides new insights into the strengths and limitations of ChatGPT in loop-to-stream refactoring and outlines potential improvements for future AI-driven refactoring tools. [ABSTRACT FROM AUTHOR]
Copyright of Future Internet is the property of MDPI and its content may not be copied or emailed to multiple sites without the copyright holder's express written permission. Additionally, content may not be used with any artificial intelligence tools or machine learning technologies. However, users may print, download, or email articles for individual use. This abstract may be abridged. No warranty is given about the accuracy of the copy. Users should refer to the original published version of the material for the full abstract. (Copyright applies to all Abstracts.)
Βάση Δεδομένων: Complementary Index
FullText Text:
  Availability: 0
CustomLinks:
  – Url: https://resolver.ebsco.com/c/fiv2js/result?sid=EBSCO:edb&genre=article&issn=19995903&ISBN=&volume=17&issue=9&date=20250901&spage=418&pages=418-444&title=Future Internet&atitle=Refactoring%20Loops%20in%20the%20Era%20of%20LLMs%3A%20A%20Comprehensive%20Study.&aulast=Midolo%2C%20Alessandro&id=DOI:10.3390/fi17090418
    Name: Full Text Finder (for New FTF UI) (ns324271)
    Category: fullText
    Text: Full Text Finder
    MouseOverText: Full Text Finder
Header DbId: edb
DbLabel: Complementary Index
An: 188278565
RelevancyScore: 1023
AccessLevel: 6
PubType: Academic Journal
PubTypeId: academicJournal
PreciseRelevancyScore: 1023.08752441406
IllustrationInfo
Items – Name: Title
  Label: Title
  Group: Ti
  Data: Refactoring Loops in the Era of LLMs: A Comprehensive Study.
– Name: Author
  Label: Authors
  Group: Au
  Data: <searchLink fieldCode="AR" term="%22Midolo%2C+Alessandro%22">Midolo, Alessandro</searchLink><br /><searchLink fieldCode="AR" term="%22Tramontana%2C+Emiliano%22">Tramontana, Emiliano</searchLink>
– Name: TitleSource
  Label: Source
  Group: Src
  Data: Future Internet; Sep2025, Vol. 17 Issue 9, p418, 27p
– Name: Subject
  Label: Subject Terms
  Group: Su
  Data: <searchLink fieldCode="DE" term="%22ChatGPT%22">ChatGPT</searchLink><br /><searchLink fieldCode="DE" term="%22Generative+artificial+intelligence%22">Generative artificial intelligence</searchLink><br /><searchLink fieldCode="DE" term="%22Software+engineering%22">Software engineering</searchLink><br /><searchLink fieldCode="DE" term="%22Software+refactoring%22">Software refactoring</searchLink><br /><searchLink fieldCode="DE" term="%22Functional+programming+%28Computer+science%29%22">Functional programming (Computer science)</searchLink><br /><searchLink fieldCode="DE" term="%22Java+programming+language%22">Java programming language</searchLink>
– Name: Abstract
  Label: Abstract
  Group: Ab
  Data: Java 8 brought functional programming to the Java language and library, enabling more expressive and concise code to replace loops by using streams. Despite such advantages, for-loops remain prevalent in current codebases as the transition to the functional paradigm requires a significant shift in the developer mindset. Traditional approaches for assisting refactoring loops into streams check a set of strict preconditions to ensure correct transformation, hence limiting their applicability. Conversely, generative artificial intelligence (AI), particularly ChatGPT, is a promising tool for automating software engineering tasks, including refactoring. While prior studies examined ChatGPT's assistance in various development contexts, none have specifically investigated its ability to refactor for-loops into streams. This paper addresses such a gap by evaluating ChatGPT's effectiveness in transforming loops into streams. We analyzed 2132 loops extracted from four open-source GitHub repositories and classified them according to traditional refactoring templates and preconditions. We then tasked ChatGPT with the refactoring of such loops and evaluated the correctness and quality of the generated code. Our findings revealed that ChatGPT could successfully refactor many more loops than traditional approaches, although it struggled with complex control flows and implicit dependencies. This study provides new insights into the strengths and limitations of ChatGPT in loop-to-stream refactoring and outlines potential improvements for future AI-driven refactoring tools. [ABSTRACT FROM AUTHOR]
– Name: Abstract
  Label:
  Group: Ab
  Data: <i>Copyright of Future Internet is the property of MDPI and its content may not be copied or emailed to multiple sites without the copyright holder's express written permission. Additionally, content may not be used with any artificial intelligence tools or machine learning technologies. However, users may print, download, or email articles for individual use. This abstract may be abridged. No warranty is given about the accuracy of the copy. Users should refer to the original published version of the material for the full abstract.</i> (Copyright applies to all Abstracts.)
PLink https://search.ebscohost.com/login.aspx?direct=true&site=eds-live&db=edb&AN=188278565
RecordInfo BibRecord:
  BibEntity:
    Identifiers:
      – Type: doi
        Value: 10.3390/fi17090418
    Languages:
      – Code: eng
        Text: English
    PhysicalDescription:
      Pagination:
        PageCount: 27
        StartPage: 418
    Subjects:
      – SubjectFull: ChatGPT
        Type: general
      – SubjectFull: Generative artificial intelligence
        Type: general
      – SubjectFull: Software engineering
        Type: general
      – SubjectFull: Software refactoring
        Type: general
      – SubjectFull: Functional programming (Computer science)
        Type: general
      – SubjectFull: Java programming language
        Type: general
    Titles:
      – TitleFull: Refactoring Loops in the Era of LLMs: A Comprehensive Study.
        Type: main
  BibRelationships:
    HasContributorRelationships:
      – PersonEntity:
          Name:
            NameFull: Midolo, Alessandro
      – PersonEntity:
          Name:
            NameFull: Tramontana, Emiliano
    IsPartOfRelationships:
      – BibEntity:
          Dates:
            – D: 01
              M: 09
              Text: Sep2025
              Type: published
              Y: 2025
          Identifiers:
            – Type: issn-print
              Value: 19995903
          Numbering:
            – Type: volume
              Value: 17
            – Type: issue
              Value: 9
          Titles:
            – TitleFull: Future Internet
              Type: main
ResultId 1