Skip to content

Working example with detailed commit history on the "pull up field" refactoring based on Fowler's "Refactoring" book

License

Notifications You must be signed in to change notification settings

kaiosilveira/pull-up-field-refactoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Continuous Integration


Pull Up Field

Before After
class Employee { ... }

class Salesman extends Employee {
  private name: string;
}

class Engineer extends Employee {
  private name: string;
}
class Employee {
  protected name: string;
}

class Salesman extends Employee { ... }

class Engineer extends Employee { ... }

Inverse of: Push Down Field

When working with inheritance, sometimes we end up creating fields that seem particular to that subclass, but in fact was already added to another subclass in the hiearchy. This refactoring helps with these cases.

Working example

Since Javascript is a dynamic language, and because in dynamic languages fields are defined the first time they're assigned to, the process of pulling up a field is the same of pulling up a constructor's body.

About

Working example with detailed commit history on the "pull up field" refactoring based on Fowler's "Refactoring" book

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project