An Empirical Study of Java Code Improvements Based on Stack Overflow Answer Edits

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Wiratsin, In-on, Ragkhitwetsagul, Chaiyong, Paixao, Matheus, De Sousa, Denis, Lapvikai, Pongpop, Haddawy, Peter
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866915606114074624
author Wiratsin, In-on
Ragkhitwetsagul, Chaiyong
Paixao, Matheus
De Sousa, Denis
Lapvikai, Pongpop
Haddawy, Peter
author_facet Wiratsin, In-on
Ragkhitwetsagul, Chaiyong
Paixao, Matheus
De Sousa, Denis
Lapvikai, Pongpop
Haddawy, Peter
contents Suboptimal code is prevalent in software systems. Developers often write low-quality code due to factors like technical knowledge gaps, insufficient experience, time pressure, management decisions, or personal factors. Once integrated, the accumulation of this suboptimal code leads to significant maintenance costs and technical debt. Developers frequently consult external knowledge bases, such as API documentation and Q&A websites like Stack Overflow (SO), to aid their programming tasks. SO's crowdsourced, collaborative nature has created a vast repository of programming knowledge. Its community-curated content is constantly evolving, with new answers posted or existing ones edited. In this paper, we present an empirical study of SO Java answer edits and their application to improving code in open-source projects. We use a modified code clone search tool to analyze SO code snippets with version history and apply it to open-source Java projects. This identifies outdated or unoptimized code and suggests improved alternatives. Analyzing 140,840 Java accepted answers from SOTorrent and 10,668 GitHub Java projects, we manually categorized SO answer edits and created pull requests to open-source projects with the suggested code improvements. Our results show that 6.91% of SO Java accepted answers have more than one revision (average of 2.82). Moreover, 49.24% of the code snippets in the answer edits are applicable to open-source projects, and 11 out of 36 proposed bug fixes based on these edits were accepted by the GitHub project maintainers.
format Preprint
id arxiv_https___arxiv_org_abs_2511_05813
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle An Empirical Study of Java Code Improvements Based on Stack Overflow Answer Edits
Wiratsin, In-on
Ragkhitwetsagul, Chaiyong
Paixao, Matheus
De Sousa, Denis
Lapvikai, Pongpop
Haddawy, Peter
Software Engineering
Suboptimal code is prevalent in software systems. Developers often write low-quality code due to factors like technical knowledge gaps, insufficient experience, time pressure, management decisions, or personal factors. Once integrated, the accumulation of this suboptimal code leads to significant maintenance costs and technical debt. Developers frequently consult external knowledge bases, such as API documentation and Q&A websites like Stack Overflow (SO), to aid their programming tasks. SO's crowdsourced, collaborative nature has created a vast repository of programming knowledge. Its community-curated content is constantly evolving, with new answers posted or existing ones edited. In this paper, we present an empirical study of SO Java answer edits and their application to improving code in open-source projects. We use a modified code clone search tool to analyze SO code snippets with version history and apply it to open-source Java projects. This identifies outdated or unoptimized code and suggests improved alternatives. Analyzing 140,840 Java accepted answers from SOTorrent and 10,668 GitHub Java projects, we manually categorized SO answer edits and created pull requests to open-source projects with the suggested code improvements. Our results show that 6.91% of SO Java accepted answers have more than one revision (average of 2.82). Moreover, 49.24% of the code snippets in the answer edits are applicable to open-source projects, and 11 out of 36 proposed bug fixes based on these edits were accepted by the GitHub project maintainers.
title An Empirical Study of Java Code Improvements Based on Stack Overflow Answer Edits
topic Software Engineering
url https://arxiv.org/abs/2511.05813