Introduce Parameter Object

 

Introduce Parameter Object is a new refactoring that replaces a set of method parameters with a new container object. All calls to the method are updated to pass the new parameter object class.


Use cases:

  1. group parameters which logically belong together; e.g., Date start, Date end, String newValue, String oldValue

  2. reduce number of parameters

  3. provide useful defaults in the parameter object

  4. pass the parameter down the call chain


Introduced in Eclipse 3.3. To execute the Introduce Parameter Object refactoring, select a method, invoke Refactor > Introduce Parameter Object, select the parameters that should be used as fields, and give meaningful names.




The following code snippet



will be modified to