Pull Up Constructor Body

Removes smells
Symptom

Multiple subclass constructors initialize the same parent fields with the same logic — every `extends Employee` constructor sets `this.name` and `this.salary` identically.

Goal

Initialization code repeated across subclass constructors moves into the parent class's constructor and is called via super.

Before the refactoring

class Manager extends Employee { constructor(n, s) { this.name = n; this.salary = s; } }
class Engineer extends Employee { constructor(n, s) { this.name = n; this.salary = s; } }

After the refactoring

class Employee {
constructor(name, salary) { this.name = name; this.salary = salary; }
}
class Manager extends Employee {}
class Engineer extends Employee {}
Example source: Illustrative example written for this site, not a quotation from any source.
Pressure

Bug fixes in init logic must land in every subclass constructor; new subclasses must remember the pattern; drift between constructors hides bugs.

Tradeoff

If only some subclasses share the init logic, pulling it up forces the others to opt out — verify the body is genuinely common.

Relief

One canonical home for parent-state init; new subclasses inherit the setup for free; bug fixes apply uniformly.

Trap

Pulling up init logic that only some subclasses share — forces the others to opt out (or override) creating a worse coupling than the original duplication.