Pull Up Field

Removes smells
Compare
Symptom
Human

A field declared identically in two or more subclasses — every subclass has `_name` with the same type, default, and visibility.

Agent

A field declared identically across multiple subclasses; the agent verifying changes to the field's shape must update every subclass consistently.

Goal
Human

A field declared identically in two or more subclasses moves to the shared superclass.

Agent

The field lives on the parent with one declaration; reading any subclass's storage resolves through inheritance to the parent's one field instead of paying the cost of loading every subclass to verify the declaration matches.

Before the refactoring

class Manager extends Employee { _name; }
class Engineer extends Employee { _name; }

After the refactoring

class Employee { _name; }
class Manager extends Employee {}
class Engineer extends Employee {}
Example source: Illustrative example written for this site, not a quotation from any source.
Pressure
Human

The shared field's type and default are duplicated; refactoring its shape means touching every subclass; the field's true ownership is muddy.

Agent

Refactoring the field's type or default requires the agent to touch every subclass; consistency drift hides bugs.

Tradeoff
Human

Pulling up a field that subclasses use differently (different default, different visibility) creates surprise — verify the field semantics are identical.

Agent

If subclasses use the field with different defaults, visibility, or semantic role, pulling up creates surprise behavior the agent must constantly disambiguate.

Relief
Human

One canonical declaration of the field's type and default; subclasses focus on what they actually specialize.

Agent

Changes to the field's type or default land in one parent declaration; generated code that constructs any subclass inherits the field without the agent having to verify that N subclasses still agree on the declaration.

Trap
Human

Pulling up a field that subclasses use differently — different defaults, different visibility, different semantic role — creates surprises where the shared declaration masks divergent uses.

Agent

Pulling up a field that subclasses use with different defaults or semantic roles creates one declaration the agent reads as shared; generated code that initializes the field at the parent level misses the subclass-specific values the original separate declarations carried.