views:

41

answers:

1

The question is about refactorings. Consider a rename method refactoring. This refactoring can be visualized as meta-method that takes old and new names, and changes the old method name to the new. so, for refactoring

foo() { ......... ......... }

to

boo() { ......... ......... }

the meta method for refactoring would be ...

renameMethod (foo, boo)

This is called parametrized refactoring. My question is can all refactorings mentioned in http://www.refactoring.com/catalog/ be thought of as having some parameters or are there refactorings that do not need such parameters?

+2  A: 

There are some "code cleanups" which don't require parameters. Whether you'd call them refactorings or not I don't know, but:

if (condition) {
    return firstValue;
} else {
    return secondValue;
}

to:

return condition ? firstValue : secondValue;

or even more so:

if (condition) {
    return true;
} else {
    return false;
}

to:

return condition;

But even within the "proper" refactoring catalog there are some which don't require parameters. For example, the hide method refactoring just makes a method private, and "reduce scope of variable" just moves a declaration.

Jon Skeet