Skip to Content
avatar image
Former Member

OO programming or Procedural?

Hello i have been working with SAP-ABAP for about 4 months and i just finished a course in OO programming. I Would like to understand if i should always program everything in OO concepts or should i use procedural programming on minor programs?

To me it seems like doing everything in OO way is the more reasonable choice because the SAP environment will then have more redundancy and will be more robust but i would like to hear some opinions about this topic from other members of the community

Regards

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Nov 23, 2017 at 09:15 AM

    You should always use OO. For a start, FORM and PERFORM are now obsolete language components. However, the main reason is that minor programs from time to time become major programs. (Can you just add this? Can you make it do that? etc.). If you've programmed it properly in the first place, the cost of maintaining and enhancing will be reduced.

    You don't have to use global classes. You can use local classes. Sometimes I've needed to make a local class global, but that's a relatively straightforward task.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 23, 2017 at 05:25 PM
    Add comment
    10|10000 characters needed characters exceeded

  • Nov 23, 2017 at 07:09 PM
    -1

    Of course, if it's a basic code of 10 lines (sometimes it's needed for interfacing two applications), I don't see why we should use OO, as the procedural way would be far more readable.

    Add comment
    10|10000 characters needed characters exceeded

    • Well... if you work for me, you must use OO. But that's mainly to get folk who are reluctant to get into the habit. It also gets people away from what I think is a very bad habit of "well, it's only 10 lines of code/a utlitiy program/a one off kind of mentality, and apply rigour and best practice to all their work.

  • Nov 27, 2017 at 07:48 AM

    Hi,

    this is maybe the better question to have a little fight between developers, and the famous INNER JOIN vs FOR ALL ENTRIES :)

    As I understood the Oo has to be used when the logic is based on the data, and the Procedural when the logic is based on the process.

    But I'm not sure it is a good idea to force people to code always in Oo, sometimes it's really difficult to debug Oo program.

    And I am curious about the memory consumption and if Oo is really faster than simple procedural program??

    Regards

    Fred

    Add comment
    10|10000 characters needed characters exceeded

    • Sometimes it’s really difficult to debug a procedural program. The reason has less to do with the strategy and more with the developer..

      The same answer applies to your question about performance etc. While oo does technically incur a small overhead, it makes strategies for efficient reuse much much easier, which more than makes up for it.

      I’ve seen well written 10,000 line procedural monsters and sprawling masses of incoherent classes. The technology was a secondary factor. The main point is that oo makes it easier and almost forces you to be better structured.