Java Reference
In-Depth Information
Changing a method's signature
The Refactor | Change Signature command ( Ctrl+F6 ) is a particularly handy
refactoring command. It lets you modify a method's signature in several ways,
including reordering the parameters, adding or removing parameters, changing
the return type, and more. Place your cursor on the method to refactor, and then
issue the refactoring command to bring up the Change Method Signature dia-
log, as shown in figure 9.21.
Changing the name is easy; change the text in the Name field. This is equiva-
lent to using the Rename refactoring we covered earlier, but it's provided here as
a convenience. You have the option of leaving the current method alone and cre-
ating a new method that delegates to the method by selecting the option. You can
also combine a name change with some of the other options available through
this dialog. The method's visibility can be changed: Select a new option from the
Visibility group. Be aware, however, that if you make a method more restricted,
you may cut it off from existing code.
Figure 9.21 Changing method signatures has traditionally resulted in broken software
builds, because developers have difficulty remembering every place a method is called.
IDEA's intelligent refactoring makes changing the signature throughout the code base
simplistic, up to and including specifying defaults for new arguments.
 
 
 
Search WWH ::




Custom Search