Skip to main content
added 9 characters in body
Source Link
Doc Brown
  • 214k
  • 34
  • 394
  • 603

FromThe refactoring 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 refactoringstep. 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.

When you want to know the name of certain refactorings, it is a good idea to check Martin Fowler's catalog first, since his list is the canonical source for most standard refactorings.

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.

The refactoring 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 step. 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.

When you want to know the name of certain refactorings, it is a good idea to check Martin Fowler's catalog first, since his list is the canonical source for most standard refactorings.

added 136 characters in body
Source Link
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 Thomas Owens already wrotementioned by Thomas Owens. However, replacing the hardcoded value is not part of that refactoring. The next 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.

From

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

to

void foo() {
  foo_ex();
}

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

is called Extract Function, as Thomas Owens already wrote. The next step

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.

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.

Source Link
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 Thomas Owens already wrote. The next step

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.