Refactoring out constants passed as parameters.

Hi

Given this:

private void RunThroughEntireSequence(object obj1, object obj2, object obj3)

{

ConcreteSequencedItem.HandleSignal(


"Step1", null, null, obj1);

ConcreteSequencedItem.HandleSignal(


"Step2", null, null, obj2);

ConcreteSequencedItem.HandleSignal(


"Finalize", null, null, obj3);

}


I wish to delegate to an override without the nulls and update all calls in my production code that are presently using "null,null".

It would make sense to me that I would use "Change Signature" at the method declaration and introduce "null" as the default value, which I can do today.
But then I would like for the refactoring to be able to search through all invocations to see if there were any invocation that was already using these default values as constants being passed, which then would be able to use the override instead.

And then, if this available, I would like to be able to access all this directly by simply invoking the refactoring from the "null" constants in the snippet above.

If I did, the following should happen:

  • The refactoring should still be called "Create override without parameter".
  • It should probably be invoking the "Change signature" dialog.
  • The specific parameter should be selected with null as its defaul value, since that is the constant that I was invoking the refactoring from.
  • There should be option to then modify only callers that are already using the same (set of) constant(s).


Something really cool would be to have an embedded search mechanism in the dialog that tells you how many callers are already using the constants in their invocation. Helps you decide wether or not the refactoring simplifies the code or not.

Please sign in to leave a comment.