Question:
Hi,
I'm working in Japan and I'm new to ABAP.
I used to program in JAVA /C++, implimenting various classes.
However, I've never seen ABAP codes that have class definitions, so far.
It seems like people write ABAP programs in procedual manner
in Japan.
I wonder if people in other countries impliment classes or
use system-defined classes start with CL_.
Could anyone kindly tell me how widely Classes are used, please?
I need to write a small report on object oriented approach in ABAP.
Thank you in advance!
Answer:
Classes are used extensively for ALV controls, web services, enhancements.
To create a local help, create a new program and have a look at the F1 help.
To create a reusable class, run SE80 and create a new class. It is quite intuitave.
To see examples, look at development class SALV. Many of these sample programs use classes.
Michael
Answer:
In my experience ABAP Objects is not widely used. Some developers have become Object aware, in that they're happy using classes already provided, but they do so in an procedural way. I do know of one software house in Germany which extensively use OO ABAP - but they started as a smalltalk company, so it isn't so surprising. In order get it really to work, they've had to split off the presentation logic - which is virtually currently impossible to do in objects - from the business and processing logic.
Unlike C++ and Java, there are not huge class libraries to leverage in your own developments. There are also differences in the way scoping and inheritance are handled.
One problem is that many procedural developers will be unable to make the conceptual leap to object oriented programming, which will slow its uptake. However, over time, OO ABAP will by necessity become the dominant technique.
OO ABAP offers most of the benefits of object oriented developers, in terms of maintainablity, flexibility, encapsulation etc.
m@t
_________________
TULY The quality of answers is roughly proportional to the quality of the question.
The downside of being better than everyone else is that people tend to assume you're pretentious.
Answer:
First of all, thanks Michael and M@t for your replies!!
It seems like OO approach is not widely used in the ABAP world.
So, is it because Objects are not well supported by ABAP language
and ABAP developers are so used to program in procedual way
that they are unwilling to move to OO programming?
Or, are there any other reasons why OO programming have not yet
used for ABAP development?
Are there any efficiency reasons to program in procedual way like
procedual programming makes programs more maintainable,
desinable, or modifiable???
Is there anyone who tried OO programming in ABAP, yet?
Could anyone give me specific examples of how OO approach is
used in ABAP, please?
Awwww...I hope ppl understand my English...(>_<)
Thanks!
Answer:
Your English is fine.
It think OO is not used widely for a number of reasons:
ABAP developers are used to programming in procedural way and see no reason to change.
A significant proportion of developers do not bother to learn good programming practice. Without those skills in procedural programming, OO is much harder to learn. I'd go further and say that OO programming is beyond the capabilities of many ABAP developers - especially those who are just itching to be promoted to the functional team...
There are no large class libraries such as for C++ or Java available from ABAP, so a lot has to be done from scratch.
I'm doing a webcast on ABAP objects at
http://expertanswercenter.techtarget.com/ in a few weeks, which might be of interest.
Is there anyone who tried OO programming in ABAP, yet?
Could anyone give me specific examples of how OO approach is
used in ABAP, please?
I don't really understand what you want. Most development requirements could be coded using OO rather than classic ABAP, if desired. There are no functionally compelling reasons to use OO. Only conceptual ones - i.e. that you get better (more maintable, more flexible, more reusable) programs with OO.
Cheers
m@t
_________________
TULY The quality of answers is roughly proportional to the quality of the question.
The downside of being better than everyone else is that people tend to assume you're pretentious.
Answer:
Thank you sooo much for your reply and info about the webcast, M@t.
I would definately check out your webcast on Dec 12!
It's kinda hard for me to explain what I want in English but I try....
My company costomizes SAP software in Japan.
At my company, all new employees, who are newly grads, including
me have to write reports on whatever we are interested in and think
useful to our work.
Since I learnt a bit of OO programming when I was a student in Canada,
I decided to write a report on OO approach in ABAP, hoping to
convince my coworkers OO programming is 'better' than Procedural programming.
(I started with OO at school and I blindly believe that OO is better,
you know...)
The thing is that I can't explain the advantages of OO to ppl
who haven't done OO programming before.
I tried to explain abstraction or polymorphism but couldn't explain it well.
I think it's almost impossible to explain those things by words.
I myself didn't understand the concept till I actually write programs.
I thought that if many companies use OO approach to write ABAP
programs abroad, I can convince my coworkers simply saying
'many companies use OO approach, cuz OO is better than
procedural.'
However, since OO approach isn't used much, I can't say that!
Now, I decided to make two programs with same functionalities;
one with procedural way and the other with OO way so that I can
actually show how things work.
I don't know if I can make it but I will try....(>_<)
Wish me luck and thanks again for your information!!
Answer:
Here's a real life example. A client has interfaces. Many of those interfaces are similar, so they'd like to group the interfaces into single programs.
Trouble is, the local sites want to be able to change the programs - and they can't do that without making everyone else regression test their changes.
With objects, you write the standard program as a class. When the local sites want to make their own localisation, they make subclasses of the relevant parts, and override methods etc. with their own requirements.
It requires a fair amount of good design up front - which can be difficult given that most development projects are reactive - but it results in far more flexible, maintainable and robust code. Localisations can be made without code duplication. Object development is therefore cheaper, and after the initial investment, quicker than procedural development.
Another direct benefit of good oo design is the elimination of case statements. The ABAP Object engine works out which subclass method to call from the object type.
m@t
_________________
TULY The quality of answers is roughly proportional to the quality of the question.
The downside of being better than everyone else is that people tend to assume you're pretentious.
Answer:
Thanks M@t for your awesome example!
Objects would surely keep the consistency of distributed
systems as in your example.
Now, I remember that I had a lecture about distributed objects
but I couldn't link that to the advantages of OO...
I was drawing a sequence diagram of my sample O-OAbap
program last night, and yea! it seems like I don't need that
many if/case statements.