In an ABAP class or ABAP interface, you can move a member definition between the public, protected, and private sections in order to switch its availability.
This refactoring option can be triggered for the following member types:
Current Section | Option 1 | Option 2 |
---|---|---|
Private | Make protected | Make public |
Protected | Make private | Make public |
Public | Make private | Make protected |
Example
Before Execution | After Execution |
---|---|
To copy the source code example, click here Code Example Before Execution |
|
The speed attribute is declared in the private section. |
The declaration of the speed attribute has has been removed from the private section and added in the public section. |
Some refactoring aids decrease (public > protected > private > local) the visibility of members of a class.
So, if the visibility of the target section is more restrictive than in the current section, the refactoring will check whether any usages exist that will no longer be available after the change. In this case, the developer is informed and can decide to reject or apply the change.
Increasing VisibilitySome refactoring aids increase (local > private > protected > public) the visibility of members or locals inside a class.
So, if the visibility of a member (or local) is increased, subsequent processing might depend on other declarations that are no longer visible for the member. In this case, the developer is informed and can decide to reject or apply the change.