While designing the application, there would be lot of instances that we need to move methods, attributes, events or types from a class to another class or an interface. Basically we need to refactor them. But we have to do it manually, it would be too costly and tedeous task when we need to do lot re-factoring. This is very simple and effective tool.
There are different scenarios when we can use Refactoring assistant. Let’s see few of them which could be used more often.
Find all the posts of Mastering the Class Editor:
- Class Editor – Convert Local Classes to Global Classes
- Class Editor – Refactoring Assistant – I
- Class Editor – Refactoring Assistant – II
Moving components from Super class to Subclass
We’ll use this class hierarchy for this demo. When we started designing, we created a single class ZCL_REPORT as shown in this UML. Now, we want to move the output related methods and attributes to the output class ZCL_REPORT_ALV. So, the final class hierarchy would look like this.
So, how we can use the refactoring assistant to do this job:
- Create a class ZCL_REPORT_ALV inheriting from ZCL_REPORT
- Change class ZCL_REPORT in SE24 and go to Utilities > Refactoring Assitant.
- You will be at Refactoring Assistant. Expand the tree.
- Drag and Drop, method GENERATE_OUTPUT and O_ALV from class ZCL_REPORT to ZCL_REPORT_ALV
This is how the class hierarchy looks after the refactoring:
In future posts, we’ll see other scenarios where we can use refactoring assistant.