Today we continue exploring the refactor methods of the NetBeans IDE, if you loved the part 1 of this post then I’m sure you have explored the rest yourselves.
No need to worry if you haven’t, we’ll explore it together.
Once again I’ll leave the obvious ones out.
Change method parameters
lets you add, remove or modify a method’s parameters the safest way.
You have to first select the method name in your source editor and click on Refactor > Change Method Parameters
With this dialog you can decide what to do with your method’s parameter and you can also change the access modifier of the method.
When you are done, just click the Refactor button to complete the whole process.
Extract Super Class
Just like the Extract Interface, it’s able to extract methods and variables from a class and based on that creates an abstract class for it. It then extends the class in question to the new abstract class.
The procedure is also simple,
make sure the targeted class is active by clicking its tab to select it or double-clicking it in the project window to open it.
Now click on the Refactor > Extract superclass button, a dialog should pop up
Select the methods and variables you would like to include in the superclass, Enter a reasonable name for the class and click on Refactor and you are done.
Move
Helps move a class to another package or project and modifies any code that references it.
One way to do this is right-click on the class either in the editor or the project window and select Refactor > move.
Make the changes required, you can even specify a new package name if it does exist, Refactor will take care of the rest and all the references made to the class in question.
Pull up
suppose you created two classes where one is superclass of the other(also works in the case where a class implements another), pull up helps move a method or a variable in the subclass to its superclass and once again Refactor takes care of the necessary steps to ensure an error free code.
Select the subclass (implementing class), click on Refactor > pull up, you should see this
Those that already checked are in the superclass ( interface ) already so all you have to do is select the methods you wish to add to the superclass ( interface ). Once you do that, the Refactor button will be enabled. You then click on it to complete the task.
There is more you can do with the Refactor. Commands like safely delete helps delete code the safest way with very little burden on your part. There are more for you to discover.
keep exploring………….
No comments:
Post a Comment