Career Corner Discussions
Join the conversation in the Career Corner group to ask career-related questions, find approaches to building skills, and seek career advancements.
cancel
Showing results for 
Search instead for 
Did you mean: 

Switch to ABAP OO

Former Member
0 Kudos
882

Hi, we consider to switch to ABAP OO but the team has only theoretical knowledge and no practical skills in objectoriented development. Especially we are completely noobs in objectoriented design. We don't know much about design patterns and how to use them appropriate. If we start an OO project on this base it might get a desaster that ends up in bad design.

Can you please give me a field report how your team did the first steps in ABAP OO? Did you just start accepting that the first results might be trash?

Thanks a lot for your advice!

1 ACCEPTED SOLUTION

matt
Active Contributor
0 Kudos
373

Probably worth getting someone in with OO design knowledge (doesn't have to be in ABAP) to check out what solutions you come up with. Even if it costs a bit extra in the short term, in the long term it could be an excellent investment. Perhaps you can get it paid for out of the training budget - "hands-on training".

I learn OO through Java, and then applied what I learned to ABAP Objects. My first few attempts weren't brilliant, but not disastrous either. You should soon pick it up. Two tips:

1. Don't be afraid to refactor when you've gone down the wrong route

2. If you find you have to refactor and it is difficult - that's a sign you've done something wrong, and really need to redesign!

9 REPLIES 9

matt
Active Contributor
0 Kudos
374

Probably worth getting someone in with OO design knowledge (doesn't have to be in ABAP) to check out what solutions you come up with. Even if it costs a bit extra in the short term, in the long term it could be an excellent investment. Perhaps you can get it paid for out of the training budget - "hands-on training".

I learn OO through Java, and then applied what I learned to ABAP Objects. My first few attempts weren't brilliant, but not disastrous either. You should soon pick it up. Two tips:

1. Don't be afraid to refactor when you've gone down the wrong route

2. If you find you have to refactor and it is difficult - that's a sign you've done something wrong, and really need to redesign!

Sandra_Rossi
Active Contributor
0 Kudos
373

My first few attempts weren't brilliant, but not disastrous either. You should soon pick it up.

I agree with Matt.

I also think that it depends on how people really implement the OO.

Some people simply migrate forms and function modules to static methods, and think it's OO.



Hi, we consider to switch to ABAP OO

why? what are you trying to achieve?

I agree with Jacques. Why do you want to switch? and for which kind of objects (some programs are much more clear and maintainable without OO)

Former Member
0 Kudos
373

There are lots of parallels between function modules and classes. Take a simple FM and rewrite it as a class. the following may be a sloppy explanation, but it helped me get started:

- Function group (FG) = Class

- Function module (FM) = Method (public)

- Global data in FG = Class attributes

- FM form (perform) = Method (private)

Create just one object (instantiation) and compare - they behave pretty much the same. Here is where the beauty of OO starts: Create another object and see how they are independent. Simple example: You load one value in global memory (FG) via a call (FM) and increment it by one via another FM. Same with the class and methods. Now if you need another value to track (say they are independent counters), the FG doesn't get you far, or you have to work with internal tables and indices or labels. With classes, you make more objects. Create counter1 and counter2 and see how they can be used without overhead.

Do a few mini examples and learn before you set up a whole project in OO. It's worth a switch, but for a few purposes (like RFCs) FMs are still good. You can mix them as needed.

Wolfgang

Former Member
0 Kudos
373

Hi Sabine Walter,

              Well,start from basic concepts of oops.try to do simple implementation.its not that much complex to learn.Will tell you some basic steps to exlore about objects.First of all here,You need to define a class and then implementation.So definition part is seperated.so you can easily understand what kind of stuff that you really implement.Well knowing theoritical knowledge is sufficient but while implementation we will face different issues.spend a day to implement methods.II mean passing arguments in methods.since its basic step to export a value to method and import a value from method.Methods have exporting importing returning changing and excepion.Next to this go for constructor and class constructor(static)then use inheritance in your program.Start using interface.In abap oop we cant implement multiple inheritance.we should use interface to achieve multiple inheritance.then go for polymorphism in your program.method overloading is not possible in ABAP objects but method over riding is possible.These are all the basic stuff you must know.for example i will put sa ple code for singleton design patten in ABAP OOPs.

Singleton:-Class is restricted to for creation of more than one instance from it.

class singleton definition create private.               "declaring class as private to resctrict

"Access specifier

  public section.

    class-methods static."static method to create instance for private

  private section.

    methods instance.'instance method to do logic

endclass.

'definition part and implementation part are seperated.it will pave the way for a good

"understandability for" desig pattern

class singleton implementation."implenting the method-place where logics are encoded

  method static.

    data obj type ref to singleton.

    create object obj."creating instance for singleton class

    call method obj->instance.

  endmethod.

  method instance.

    write 'SINGLETON'.

  endmethod.

endclass.

start-of-selection."""""""""""start of a program.,

call method singleton=>static."""""calling a  static method in singleton class.instance will be created "and instance method is called from this method.

Like this Abstrat,Factory methods can also be done in ABAP OO.

Patrick_vN
Active Contributor
0 Kudos
373

If you're serious on this, take some time to learn from the master: http://scn.sap.com/people/thomas.jung/blog/2009/08/11/basic-abap-oo-elearnings

0 Kudos
373

I advise only parts 1 and 2! The other parts are about MVC, BSP, persistence, that would confuse more than giving a good insight

nomssi
Active Contributor
0 Kudos
373

Hello Sabine,


Hi, we consider to switch to ABAP OO

why? what are you trying to achieve?

SAP recommends ABAP Objects because stricter syntax checks are enforced. It is an implicit switch to abandon backward compatibility, many obsolete forms are not allowed. If this is your goal, follow Wolfgang Propfe's advice (to which I add: use lots of local classes). I guess this is what everybody is doing.


If we start an OO project on this base it might get a desaster that ends up in bad design.

If design is your concern then you want to educate your team about design concepts. Now this is something you have to fight for, speicially if your organization does not see itself as a software development entity. All this trainings and Reviews[1] have a price... so what is the business case? And while you are at it, do not stop at the old OO buzzword, check e.g. Domain Driven Design or functional reactive programming...


Can you please give me a field report how your team did the first steps in ABAP OO? Did you just start accepting that the first results might be trash?

Instead of worrying about first results, think about improvements in your software development process. e.g. how is your software managed? how is the specification gathered/documented? Do you have a Change management in place? Any large code base has some "trash" that can be improved in its Life Cycle if the Software development process is effective.

best regards,

JNN

[1] Booch et al, Object-Oriented Analysis and Design With Applications, Third Edition - Chapter 7 - Pragmatics

former_member243278
Participant
0 Kudos
373

Dear Sabine,

Firstly, you should have at least one person who know object oriented programming logic and patterns in your team. If you do not have a senior OOP developer in project, you cannot understand that is it the right way or not. One senior developer can be a control point and evaluate project process technically.

From technical perspective there are lots of documents for OO-Design Patterns in the internet. It is not necessary to learn with ABAP to understand design patterns. You can also use Java, C# or C++ documents for design patterns. However there is a SAP PRESS book for ABAP-OO Design patterns. Here is the link; Design Patterns in Object-Oriented ABAP. von Igor Barbaric - by SAP PRESS

And also there is another book for Object Oriented ABAP powered by SAP PRESS again; Object-Oriented Programming with ABAP Objects. von Ja - by SAP PRESS

This book will be enough to learn and apply your learnings to business process. Your team just need some time to handle OO design patterns. If you have experienced team in development, it will not take so much time to understand.

Jelena_Perfiljeva
Active Contributor
0 Kudos
373

I'd recommend reading this blog, as well as all others by Paul Hardy and his book, of course.