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.