Compare
Symptom
Human

A function body that needs a mental outline before it can be read — multiple concerns interleaved, or chunks of statements that share a single domain purpose without a name. The reader's rises because every read reconstructs the outline; small edits to one concern require holding all the others in working memory.

Agent

A function whose exceeds the agent's reliable chunk-reasoning budget; verifying behavior preservation requires re-reading the entire span on every edit. The of the unstructured body crowds out other reasoning, and the count rises as the agent re-derives the function's internal structure on each read.

Goal
Human

Each function reads as a single named domain step — what it does, not how. The calling code becomes a sequence of named intentions; readers verify the workflow at the top level and drill into helpers only when the named step's body is the point of interest, supporting at the procedural level.

Agent

Each function is a verifiable unit small enough that the agent reasons about its full behavior in a single reasoning step. The agent's holds the relevant helper and its signature; verifying behavior touches one named unit, and the of any edit drops because the agent doesn't re-derive structure on each read.

Before the refactoring

function invoiceTotal(invoice) {
let total = 0;
for (const line of invoice.lines) {
total += line.qty * line.unitPrice;
if (line.qty >= 100) total -= line.qty * line.unitPrice * 0.05;
}
total += total * invoice.taxRate;
return Math.round(total * 100) / 100;
}

After the refactoring

function invoiceTotal(invoice) {
const subtotal = subtotalAfterBulkDiscount(invoice);
const withTax = subtotal * (1 + invoice.taxRate);
return roundToCents(withTax);
}
Example source: Illustrative example written for this site; the refactoring itself is catalogued in Martin Fowler's Refactoring (Addison-Wesley, 2018), see the chapter on A First Set of Refactorings.
Pressure
Human

Every reader pays the outline cost on every read; small edits to one concern require holding all the others in working memory, and PRs touch the same function for unrelated reasons. The team's compounds across reviewers who must re-derive the function's structure each time; merge conflicts collect at the same body.

Agent

Every edit pays full re-read cost; chained changes compound context usage and increase the chance of missing a cross-statement invariant. The agent's multiplies with body length — verifying any single change requires scanning every other statement to confirm it didn't shift, and the agent's on chained edits compounds.

Tradeoff
Human

Over-eager extraction can produce a fan-out of one-line functions; aim for extractions that earn their name with at least one decision or transformation. The team's can rise rather than drop if the extractions don't carry domain meaning, because every helper becomes a name to find, load, and verify on every traversal.

Agent

Each extracted helper inflates the agent's context-window load by one definition the next reasoning step must load; over-extracting saturates the agent's effective context-window capacity. The agent's rises during the extraction itself — every reference to the body must be confirmed to route through the new helper rather than continuing to inline what's left.

Relief
Human

Calling code becomes a sequence of named intentions; bugs concentrate inside the now-named subroutines because the reader can localize the failure to one named step. The team's drops because adding a new step is one new function rather than a new branch inside an already-cluttered body, and tests target the helper directly.

Agent

Each extracted helper fits inside one read; the agent verifies behavior against one signature instead of loading the entire original procedure into context to detect what changed. The agent's token cost per edit drops because the relevant unit is the helper, not the parent — and helper boundaries surface cross-statement invariants through rather than runtime drift.

Trap
Human

Tiny one-line helpers where the workflow can no longer be read linearly — extraction that doesn't earn its name fragments the procedure into pieces too small to mean anything. The fan-out adds to the call graph; readers carry the of jumping between trivial helpers to reconstruct the original procedure.

Agent

Forces the agent to chase a dozen function definitions to follow what was once a 20-line procedure — context cost inflates and cross-function invariants disappear. The agent's retrieval cost across the call graph rises faster than the per-helper context-window load drops; tiny helpers cost more to assemble than to inline.