Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Define local classes in function groups

0 Kudos

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

3 REPLIES 3

Former Member
0 Kudos

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

0 Kudos

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.

0 Kudos

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