Pull members up, push members down
The Pull Members Up refactoring lets you move fields if two classes have the same field, or move methods if your subclasses have methods performing similar work. This helps you to get rid of duplicate code. You can also move class members to a superclass or an interface, or interface to superinterface.
The Push Members Down refactoring lets you clean up the class hierarchy by moving class members to a subclass or a subinterface. The members are then relocated into the direct subclasses/interfaces only. This improves internal class coherency.
Select an item you want to pull up or push down.
From the main or context menu, select Refactor | Pull Members Up or Refactor | Push Members Down.
In the dialog that opens, depending on your refactoring, specify a destination object, members you want to move, and other additional information.
Click Refactor.
Before | After |
---|---|
|
|
Before | After |
---|---|
|
|
Thanks for your feedback!