Apply refactorings
Symptom
A class field used by only one method, set to null or default the rest of the time.
Goal
The temporary state moves to a dedicated class that exists only when it's relevant.
Smellier version
class Order {shippingTrack = null;ship() {this.shippingTrack = computeTrack();}}
Fresher version
class Order { ship() { return new Shipment(this); } }class Shipment { /* owns the track */ }
Pressure
Reader must trace the conditions under which the field is meaningful; null-checks scatter; the field's role is unclear.
Tradeoff
Extracting the temporary state to a dedicated class adds a new type the team must learn; for one-shot uses the class can feel like more ceremony than the original field.
Relief
Null-checks vanish; class invariants tighten; the new class has a clear purpose.
Trap
Extracting a class for every short-lived field — including ones whose 'temporary' use is genuinely local and well-encapsulated by the host class.