SAP CLASS SIZE - Guide
Get Example source ABAP code based on a different SAP table
GUIDELINE 4.24
Class Size
ABAP_BACKGROUND
The class size is the number of components (attributes, methods, events) of a class. The
ABAP_RULE
Ensure that classes and interfaces do not contain an excessively high number of attributes, methods and events. The components contained must be class-specific and should not handle tasks that are extremely different from each other. The same applies to function groups.
ABAP_DETAILS
Complexity is not only important on the level of procedure implementations. The number of procedures to be considered and the data processed by these procedures are also very important when it comes to understanding the source code.
A class, interface or function group should not be mistaken as a container that can be used for any functionality. Function groups play the same role here as abstract final classes, which you cannot generate instances of. The function modules correspond to static public methods, and the global data corresponds to private static attributes. The situation should be viewed more as an abstraction of a certain subject or an object from real life. This modularization of a complex problem in objects of a manageable size makes it easier to understand the code. Therefore, the classes and interfaces must be designed appropriately and each class/interface must cover a manageable function that is easy to understand.
This is obviously not the case, if a class or an interface contains a large number of attributes and methods. The same applies to the number of function modules of a function group (with regard to the use of
Besides the high degree of complexity, which makes it more difficult to maintain voluminous classes and function groups, you must consider another technical aspect: Even if you use a small part of the provided functionality, the entire class/function group is loaded into the program memory, which negatively impacts the memory usage.
Note
It is
Functionality that is only required in a global class, function group or any other program, should therefore be encapsulated in local classes. (All functions of function groups, subroutine pools, and executable programs
This procedure is also useful for global classes. By moving highly specialized functionality to smaller, local classes, you reduce the number of methods of the global class, which results in a clearer overview and makes the class easier to maintain. When you use local classes within global classes, make sure you position them appropriately to