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.