Rename Field

Removes smells
Compare
Symptom
Human

A class field whose name is ambiguous (`name` on a Position class — role name or person?), shadowed by language keywords, or describes implementation type rather than domain role.

Agent

A field whose name does not match its role in the domain; every read or write site forces the agent to load the class definition to recover what the field represents before reasoning about the access.

Goal
Human

Field names match the domain role they play; readers don't need to inspect usage to know what a field means.

Agent

Field names carry the domain term; read or write sites resolve to one token of name without loading the class definition for context recovery.

Before the refactoring

class Position {
name; // role name? or person's name?
hiringManager;
}
console.log(position.name); // ambiguous

After the refactoring

class Position {
title;
hiringManager;
}
console.log(position.title); // clearly the role
Example source: Illustrative example written for this site, not a quotation from any source.
Pressure
Human

Every reader/writer of the class must figure out what the field means from context; bugs surface when readers assume the wrong meaning.

Agent

Every access site pays the cost of loading the class definition to recover what the field stores; tokens consumed scale with the number of consumers, and generated code that misinterprets the field's role ships against the wrong invariant.

Tradeoff
Human

Same drift as Rename Variable, amplified across the field's read/write surface and any persistence shadows (DB columns, JSON schemas, APIs).

Agent

Renaming a field invalidates more cached associations than a variable rename — persistence layers (DB columns, JSON schemas, API contracts) carry the old name until they update.

Relief
Human

Stronger encapsulation; future readers read the class definition and immediately understand its shape.

Agent

Field reads and writes resolve to one token of name without loading the class definition to recover what the field stores; the name is what the agent edits against in subsequent steps.

Trap
Human

Renaming a field without updating the persistence shadow — DB columns, JSON schema, API responses still use the old name and break serialization/deserialization silently.

Agent

Renaming a field whose current name another reviewer would have accepted forces coordinated migrations across every external surface (database columns, JSON schemas, API contracts) without changing what the field stores.