A class field used by only one method, set to null or default the rest of the time.
A class field the agent finds set to null or default for most of the object's lifetime, populated only inside one method's flow — the agent must verify which methods care.
The temporary state moves to a dedicated class that exists only when it's relevant.
Temporary state lives in a dedicated class that exists only when relevant; the agent loads the temporary type only when reasoning about that flow.
Smellier version
class Order {shippingTrack = null;ship() {this.shippingTrack = computeTrack();}}
Fresher version
class Order { ship() { return new Shipment(this); } }class Shipment { /* owns the track */ }
Reader must trace the conditions under which the field is meaningful; null-checks scatter; the field's role is unclear.
The agent must trace the conditions under which the field is meaningful; null-checks scatter across consumers; class invariants weaken because the field has no defined lifecycle.
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.
Extracting a new class adds a type the agent must load to reason about the flow; for genuinely one-shot uses the class is more code than the original field warranted.
Null-checks vanish; class invariants tighten; the new class has a clear purpose.
Null-checks vanish; the agent reasons about a class with a clear lifecycle; class invariants tighten so reasoning about the host class doesn't have to consider the unused state.
Extracting a class for every short-lived field — including ones whose 'temporary' use is genuinely local and well-encapsulated by the host class.
Extracting a class for every short-lived field — including ones with truly local use — creates new types the agent must load with no comprehension gain over the original encapsulated field.