Home > Refactorings > Refactorings – Add Parameter

Refactorings – Add Parameter

August 13th, 2010

The refactoring adds a new parameter to a method declaration and updates all calls accordingly. This refactoring is useful when you need to quickly add a new parameter to an existing method because it needs more information from its caller that wasn’t passed in before. Bear in mind that if there are alternatives available against doing this refactoring, it is preferred to use those alternatives instead, because they don’t lead to increasing the length of parameters lists. Long parameter lists are hard to remember and often involve data clumps.


The opposite of this refactoring is the Remove Parameter refactoring. As an alternative you may use the Introduce Parameter Object refactoring, which consolidates selected parameters of a method into a single class or structure, and simplifies the method’s parameters list.


Refactor! Add Parameter preview

The interactive phase of refactoring:

Refactor! Add Parameter preview


Refactor! Add Parameter preview


  • This refactoring enables Text Fields to make it easier for you to type the parameter type and name.
  • Once you’ve finished entering the parameter type and name, each method call is updated with a new parameter. An empty value corresponding to the specified type is used by default (0 for integer, String.Empty for string, etc).
  • Automatically created Navigation Links allow you to easily navigate through all method calls and change default parameter values.
  • A marker is dropped at parameter declaration statement. This allows you to easily get back to the method declaration when you are done with parameter values.
  • The refactoring is pretty simple and doesn’t have any options available.
Products: CodeRush Xpress, Refactor! Pro and free editions of Refactor!
Versions: all
VS IDEs: any
Updated: Sep/26/2010
ID: R011

Similar Posts: