Skip to content

Rename Field

Field names are the vocabulary of a data structure. When a field is called name but actually holds a customer’s title, or date when it really stores a creation timestamp, the name lies, and every reader pays a small tax to decode it. Rename Field changes the field to a name that matches what it now holds, and updates everything that reads or writes it. The data structure starts telling the truth again.

The smell is a field name that no longer matches its data. Names drift as software grows: a field added for one purpose gets reused for another, a domain term changes, or the original name was simply vague. You notice it when the name needs a comment to explain it, when newcomers consistently misread it, or when the field’s name and its actual usage have quietly diverged. A stale name is a small but constant source of misunderstanding.

A customer record whose field is called name but holds a formal title. After, it is renamed title, with accessors updated so callers read the clearer name.

// Before
interface Customer {
name: string; // actually a formal title like "Dr."
email: string;
}
function greet(c: Customer): string {
return `Welcome, ${c.name}`;
}
// After
interface Customer {
title: string;
email: string;
}
function greet(c: Customer): string {
return `Welcome, ${c.title}`;
}
  1. If the record is small and entirely under your control, your editor’s rename-symbol refactoring can do the whole job in one safe step — use it and run your tests.
  2. For a widely used or externally shared record, go incrementally. First, if the field is not already encapsulated, hide it behind a getter and setter so callers depend on accessors rather than the raw field.
  3. Rename the underlying field, keeping the accessors temporarily named for the old name. Run your tests.
  4. Rename the getter and setter to the new name, updating call sites in small batches. Run your tests after each batch.
  5. If the field is serialised (JSON, a database column, a wire format), keep the persisted key stable with an explicit mapping — or migrate it deliberately — so you do not break stored data or other services.
  6. When every reader and writer uses the new name and any serialisation mapping is settled, the rename is complete.

Rename Field is worth doing the moment a name causes a misread, because the cost of a confusing name compounds with every person who reads it. It is cheapest on small, internal structures where a tool-assisted rename is instant and safe.

The hazard is reach. A field can be referenced far beyond your file: in serialised payloads, database schemas, API contracts, or other repositories you do not control. For those, a blind rename breaks consumers. Decouple the internal name from the external one — map the new field name to the old serialised key — or run a planned migration. When in doubt about who reads the data, encapsulate first and rename behind that boundary.

What problem does Rename Field solve?
For a small, fully internal record, what is the safest fastest approach?
Why is renaming a serialised field riskier than renaming a local one?
What protects consumers when a field that escapes your module must be renamed?