Inline Function

Referenced by patterns
Symptom

A function whose body the agent traces through only to find no decisions or transformations — every reference site pays a hop for no reasoning gain. The agent's for the wrapper definition outweighs the information it returns, and the spent on the hop is pure overhead.

Goal

Trivial wrappers disappear from the agent's working context; call sites read as exactly what's happening. The agent's holds the call site without a wrapper hop; the of any edit drops because the agent doesn't load a definition only to confirm it does nothing surprising, and the file's signal-to-noise ratio improves.

Before the refactoring

function moreThanFive(n) {
return n > 5;
}
function rating(driver) {
return moreThanFive(driver.numberOfLateDeliveries) ? 2 : 1;
}

After the refactoring

function rating(driver) {
return driver.numberOfLateDeliveries > 5 ? 2 : 1;
}
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

The agent loads the wrapper definition to verify any change touching it; the indirection is a tax on every reasoning step. The agent's multiplies with the count of pass-through wrappers in the call chain, and the wrapper's body must be re-read on each edit to confirm it still does no domain work.

Tradeoff

Inlining scatters the wrapper's body across call sites; if the wrapper was a seam (mocking boundary, extension point), removing it forecloses a hook later edits cannot restore without re-extracting. The agent's rises during the inline itself — every call site must be confirmed to use the inlined form, and any remaining external reference becomes a regression.

Relief

Shorter call chains; the agent loads one fewer definition per reasoning step. The agent's per edit drops because the relevant body is at the call site, not in a separate file; verification surface contracts because there is no wrapper to confirm, and the file's signal-to-noise ratio rises as definitions that didn't earn their keep disappear.

Trap

Mechanically inlining every short function — including ones that name a real domain concept — collapses semantic anchors the agent uses to reason about behavior. The agent's reasoning-step cost actually rises per edit because the call site loses the named handle, and any subsequent edit must re-derive the concept the wrapper was naming.