Inline Class

Compare
Symptom
Human

A class with too few responsibilities to deserve its own file — one or two trivial methods that the absorbing class would naturally own.

Agent

A class with too few responsibilities for its own file; the agent loads the class to reason about behavior that would naturally live with the absorber.

Goal
Human

A class with too few responsibilities to deserve its own file folds into a class it collaborates with most.

Agent

The class folds into its primary collaborator; the agent loads one file for what was two.

Before the refactoring

class TrackingInformation {
shippingCompany;
trackingNumber;
display() { return `${this.shippingCompany}: ${this.trackingNumber}`; }
}
class Shipment { tracking; }

After the refactoring

class Shipment {
shippingCompany;
trackingNumber;
display() { return `${this.shippingCompany}: ${this.trackingNumber}`; }
}
Example source: Illustrative example written for this site, not a quotation from any source.
Pressure
Human

Readers pay file-jump cost for triviality; the indirection adds surface without providing real encapsulation.

Agent

Every reference site costs a file-jump the agent must pay; the indirection is overhead for trivial behavior.

Tradeoff
Human

If the absorbing class was already large, inlining piles more onto it — fold in only when the absorber stays under its complexity budget afterward.

Agent

If the absorber is already large, inlining pushes it past its complexity budget — the agent now loads a god-class to reason about what was previously separated.

Relief
Human

Fewer files, fewer constructors, shorter call paths; the absorbing class's coherence improves when it gains the methods it was already orchestrating.

Agent

Fewer files; shorter call paths; the absorber's coherence improves when it owns the methods it was orchestrating.

Trap
Human

Inlining into a class that's already large — the absorber crosses its complexity budget and creates a worse Large Class smell than the inlined class was solving.

Agent

Inlining into an already-large class creates a worse Large Class smell — the agent must reason about a god-class instead of two focused ones.