Inline Class

Symptom

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

Goal

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

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

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

Tradeoff

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

Relief

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

Trap

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.