Skip to main content
2 of 3
added 136 characters in body
Doc Brown
  • 214k
  • 34
  • 394
  • 603

From

void foo() { 
  bar1(9); 
  bar2(9); 
}

to

void foo() {
  foo_ex();
}

void foo_ex() {
  bar1(9);
  bar2(9); 
}

is called Extract Function, as mentioned by Thomas Owens. However, replacing the hardcoded value is not part of that refactoring. The step to

void foo() {
  foo_ex(9);
}

void foo_ex(int x) {
  bar1(x);
  bar2(x); 
}

is called Parameterize Function. It max be also seen as a special case of Change Function Declaration.

Doc Brown
  • 214k
  • 34
  • 394
  • 603