How Developers Extract Functions: An Experiment
Alexey Braver, Dror G. Feitelson

TL;DR
This study empirically investigates how developers decide to extract functions during refactoring, revealing tendencies based on structural cues and variability in refactoring extent among developers.
Contribution
It provides the first empirical analysis of developer decision-making in function extraction, highlighting common patterns and differences in refactoring behavior.
Findings
Developers tend to extract functions around structural cues like 'if' or 'try' blocks.
Significant correlation exists in refactoring patterns among developers.
The number of functions extracted varies from 3 to 10, with 37% to 95% of code refactored.
Abstract
Creating functions is at the center of writing computer programs. But there has been little empirical research on how this is done and what are the considerations that developers use. We design an experiment in which we can compare the decisions made by multiple developers under exactly the same conditions. The experiment is based on taking existing production code, "flattening" it into a single monolithic function, and then charging developers with the task of refactoring it to achieve a better design by extracting functions. The results indicate that developers tend to extract functions based on structural cues, such as 'if' or 'try' blocks. And while there are significant correlations between the refactorings performed by different developers, there are also significant differences in the magnitude of refactoring done. For example, the number of functions that were extracted was…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Engineering Research · Software Testing and Debugging Techniques · Software Reliability and Analysis Research
