01-10-2006 8:07 AM
Hi,
I have seen in few code examples that programmers defined their classes as follows:
1. Interfaces are defined globally i.e. under package->class library->interfaces.
2. implementing classes are defined locally under: package->function group (as public local class in the function group).
My question is What is the advantage/disadvantage of it?
(beside encapsulation).
I heard that the class loader is working better in that way, is that right?
thanks,
Yaron
01-10-2006 9:12 AM
Hi
Interfaces is like an empty box, so only definition exists.
The implemantation is locally done, so you can have several objects (class) have the same covering (methods, variables,...) but they are different.
So you can have methods have the same interface, but make different actions.
The BADI, for example, are based on this concept.
In the standard there's only the call of a method of a interface, so I can link this interface to my class and implement the method inserting the code I need.
Max
01-10-2006 10:04 AM
Hi Max,
Thanks for your reply, but I guess I didn't explain the question well.
I am well familiar with OO programing, and what is the advantage of using interfaces.
my concern is wether to define these classes globally (transaction SE24), or locally in function group(expose the class to the 'world' by global interface).
I heard that the ABAP class loader is working better if you define all classes in one function group (load all classes once), but I didn't see any formal guideline/documentation about it.
thanks,
Yaron.
01-10-2006 10:29 AM
Hi
excuse me I miserunderstood.
Perhaps it's true I don't know.
I think the different is the SE24 is a library, so it's the tool arranged to analyze all class components you can need.
I don't think it's easier to analyze an include (function group) where the class is defined and implemented.
You shuold measure the time in order to load the class for both case, but probably the different isn't meaningful.
You should consider that ABAP wasn't OO language, but it was adapted for OO, and so the most ABAP developer weren't used to use OO.
I think you should define a class as local class if it's your own class.
Max
Message was edited by: max bianchi