# What extraction cannot slim, and whether function injection can: a pre-registered study of 580 Java repositories

DevFeed: [What extraction cannot slim, and whether function injection can: a pre-registered study of 580 Java repositories](<https://devfeed.tech/articles/what-extraction-cannot-slim-and-whether-function-injection-can-a-pre-registered-study-of-580-java-repositories-127236.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2611.10545>)

Author: Daniel Sagenschneider

Published: 2026-11-10T05:00:00Z

Content type: news

Language: en

Sources: [arXiv: Software Engineering](<https://devfeed.tech/sources/arxiv-software-engineering.md>)

Topics: [coding patterns](<https://devfeed.tech/topics/coding-patterns.md>), [Dependency injection](<https://devfeed.tech/topics/dependency-injection.md>), [return](<https://devfeed.tech/topics/return.md>), [Open Source](<https://devfeed.tech/topics/open-source.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [ai-assistants](<https://devfeed.tech/tags/ai-assistants.md>), [ai-coding-assistants](<https://devfeed.tech/tags/ai-coding-assistants.md>), [code](<https://devfeed.tech/tags/code.md>), [costs](<https://devfeed.tech/tags/costs.md>), [cs-se](<https://devfeed.tech/tags/cs-se.md>), [exit](<https://devfeed.tech/tags/exit.md>), [framework](<https://devfeed.tech/tags/framework.md>), [functions](<https://devfeed.tech/tags/functions.md>), [hypothesis](<https://devfeed.tech/tags/hypothesis.md>), [java](<https://devfeed.tech/tags/java.md>), [literals](<https://devfeed.tech/tags/literals.md>), [logic](<https://devfeed.tech/tags/logic.md>), [nested](<https://devfeed.tech/tags/nested.md>), [plan](<https://devfeed.tech/tags/plan.md>), [random](<https://devfeed.tech/tags/random.md>), [reading](<https://devfeed.tech/tags/reading.md>), [repositories](<https://devfeed.tech/tags/repositories.md>), [return](<https://devfeed.tech/tags/return.md>), [sample](<https://devfeed.tech/tags/sample.md>), [study](<https://devfeed.tech/tags/study.md>)

## AI overview

In a pre-registered scan of 3,026,902 methods from 580 Java repositories pinned before AI coding assistants were widely used, single-exit extraction could not slim 22.8% of long methods. Function injection, which splits code into framework-injected and sequenced functions that can end early and pass multiple values, handled 22.2% of those stuck methods (95% CI 20.3-24.3), refuting the hypothesis that it would handle at least a quarter. Nearly half of the stuck methods were early-return cases counted as conventionally fixable; injection split three quarters of those as written. Where extraction was possible, injection had lower estimated cost in 29.0% of cases versus extraction wrapped as one function and 17.2% versus plain extraction, usually using a straight function sequence. Among methods neither approach split, many were long because of tables or literals; others were blocked by loop jumps, oversized nested statements, or too many values. The findings come from the stated sample and fixed cost models; the authors propose follow-up studies, including on AI-assisted code.

## Source excerpt

arXiv:2611.10545v1 Announce Type: new Abstract: A method of 26 code lines or more reads as a Long Method, and Extract Method is the usual fix. Some long methods have no single-exit fix: a return cannot leave an extracted piece, a piece hands back one value, and some methods are knotted so that every cut is blocked. Function injection, as the OfficeFloor framework does it, cuts differently: each piece becomes a function the framework injects and sequences, an early return ends a function, and a function hands on several values. The framework's author pre-registered a test of whether it takes apart what extraction cannot. A stratified random sample of 580 open-source Java repositories, each pinned before AI coding assistants were in general use, was scanned by released tools whose cost models were fixed before the sample was drawn: 3,026,902 methods, 168,466 of them long. Single-exit extraction cannot slim 22.8% of the long methods. The registered hypothesis, that at least a quarter of those stuck methods are ones only function injection takes apart, is refuted: 22.2% (95% CI 20.3 to 24.3). Nearly half of the stuck methods are early-return methods the plan counts as conventionally fixable, and the split takes three in four of those apart as they stand. Where extraction would do, the split chooses injection and costs less for 29.0% against extraction wrapped as one function and 17.2% against plain extraction, almost always as a straight sequence of functions. An exploratory reading of the quarter of the stuck methods that neither takes apart finds a third of it tables and literals, long for their data rather than their logic, and most of the rest blocked by a jump inside a loop, by a nested statement too large to cut, or by values too many for any cut. Three registered studies are proposed: the classes as rules in the tools, a refinement per class, and the same measures on code written with AI assistants.