<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: When should I write a class instead of a function module? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345216#M1992388</link>
    <description>&lt;P&gt;Exactly that. This is an occasion where a static method is appropriate - when you want to control instantiation in the class. Singleton and factory pattern.&lt;/P&gt;</description>
    <pubDate>Mon, 11 Jan 2021 07:45:24 GMT</pubDate>
    <dc:creator>matt</dc:creator>
    <dc:date>2021-01-11T07:45:24Z</dc:date>
    <item>
      <title>When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345204#M1992376</link>
      <description>&lt;P&gt;Hello experts,&lt;/P&gt;
  &lt;P&gt;I am familiar with functions modules and function group, but not with classes.&lt;/P&gt;
  &lt;P&gt;When should I write a class instead of a function module?&lt;/P&gt;
  &lt;P&gt;(I search for a clear answer but could not find)&lt;/P&gt;
  &lt;P&gt;Thanks in advance&lt;/P&gt;
  &lt;P&gt;Hagit&lt;/P&gt;</description>
      <pubDate>Sun, 27 Dec 2020 16:49:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345204#M1992376</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2020-12-27T16:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345205#M1992377</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In my personal opinion there are mainly 3 reasons to still use function modules, these cases are:&lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;You need an RFC / Update task enabled logic (e.g. to call it from an external system)&lt;/LI&gt;&lt;LI&gt;You need to use screens (using screens is not possible in classes directly)&lt;/LI&gt;&lt;LI&gt;You need to write logic which is to be hooked into certain frameworks which are not ABAP OO-enabled&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Personally I always write my core logic in classes and if I need the logic to be RFC enabled, I just write a wrapper function module around my class-based logic.&lt;/P&gt;&lt;P&gt;When using screens I even divide the logic in three parts:&lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;Core logic (class, in which you never use function modules which use screens)&lt;/LI&gt;&lt;LI&gt;Screen logic (function modules)&lt;/LI&gt;&lt;LI&gt;Application logic (class, which calls the screen logic function modules)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;But again this is a personal opinion, I don't think there's just one answer to this question. Both ways of working, work perfectly although object oriented programming is more future proof and definitely the way to go.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Geert-Jan Klaps &lt;/P&gt;</description>
      <pubDate>Sun, 27 Dec 2020 17:31:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345205#M1992377</guid>
      <dc:creator>geert-janklaps</dc:creator>
      <dc:date>2020-12-27T17:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345206#M1992378</link>
      <description>&lt;P&gt;thanks for your answer.&lt;/P&gt;&lt;P&gt;Why do you think that a static method
in a class  is better than a function
module?&lt;/P&gt;</description>
      <pubDate>Sun, 27 Dec 2020 19:51:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345206#M1992378</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2020-12-27T19:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345207#M1992379</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;There's no real advantage here, both a function module or a static method can be used to hold your logic. Although a class-based approach (using static or instance methods) in general is better than using function modules, since you can make use of certain features like better error handling using exception classes, method chaining, ...&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Geert-Jan Klaps&lt;/P&gt;</description>
      <pubDate>Sun, 27 Dec 2020 20:43:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345207#M1992379</guid>
      <dc:creator>geert-janklaps</dc:creator>
      <dc:date>2020-12-27T20:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345208#M1992380</link>
      <description>&lt;P&gt;One additional point I want to add as a pro argument for classes/interfaces is the better testability. Instead of blowing up your productive code with test-seams in case of functions, you can use the test double framework to create test doubles for based on interfaces.&lt;/P&gt;&lt;P&gt;To take advantage of that pro argument, you need to do unit testing of course, but I guess that is already a standard nowadays :-).&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 06:25:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345208#M1992380</guid>
      <dc:creator>pfefferf</dc:creator>
      <dc:date>2020-12-28T06:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345209#M1992381</link>
      <description>&lt;P&gt;There are very good reasons why you should always use a class and Mehtods. Function modules are only appropriate if you are forced to do so for technical reasons. But that is rarely the case. &lt;BR /&gt;In addition to the points mentioned by  &lt;SPAN class="mention-scrubbed"&gt;8d8214c7f9734f45be69f95cc0d5aeee&lt;/SPAN&gt;  and  &lt;SPAN class="mention-scrubbed"&gt;florian.pfeffer&lt;/SPAN&gt; here are some more advantages of classes/methods:  &lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;Type checking at design time for method calls. In contrast, function modules are checked at runtime, leading to dumps in case of incompatibilities. This is the most important advantage of static methods!&lt;/LI&gt;&lt;LI&gt;Better control over the reusability or visibility of methods with the keywords PUBLIC, PROTECTED and PRIVATE.&lt;/LI&gt;&lt;LI&gt;In general: All the advantages of Object Oriented Programming over Functional Programming.  For example, encapsulation of data, inheritance, polymorphism and interfaces. &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;To benefit from this, you need to learn and understand the concepts of Object Orientation. And you have to get involved with it. But then they have a huge advantage for ABAP developers. &lt;/P&gt;&lt;P&gt;Regards, &lt;/P&gt;&lt;P&gt;Jörg&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 07:34:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345209#M1992381</guid>
      <dc:creator>Jrg_Brandeis</dc:creator>
      <dc:date>2020-12-28T07:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345210#M1992382</link>
      <description>&lt;P&gt;Thank you for your valuable answer. It is pity that I can not mark more
the on answer as Best answer&lt;/P&gt;&lt;P&gt;Hagit &lt;/P&gt;</description>
      <pubDate>Sun, 03 Jan 2021 11:33:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345210#M1992382</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2021-01-03T11:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345211#M1992383</link>
      <description>&lt;P&gt;Four reasons to use a static method of a class instead of a function module&lt;/P&gt;&lt;P&gt;1. The syntax is neater&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;class=&amp;gt;_do_my_stuff( importing .... exporting ...) &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;result = class=&amp;gt;_do_my_stuff( ... ).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;against&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CALL FUNCTION 'Z_DO_MY_STUFF'...&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2. The name of the method and class are checked at syntax check time, as are parameter types. No more "function not found" dumps due to a typo. No more conversion errors.&lt;/P&gt;&lt;P&gt;3. You can group related methods together rather more conveniently than with FM&lt;/P&gt;&lt;P&gt;4. They work better when programming in Eclipse!&lt;/P&gt;&lt;P&gt;I only use FM for screen handling and where I need RFC. The &lt;EM&gt;work&lt;/EM&gt; of the FM is done using local or global classes.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 07:04:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345211#M1992383</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2021-01-04T07:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345212#M1992384</link>
      <description>&lt;P&gt;I put all my FM calls into a local class impelementing a local interface. That way, I can test without using test-seams. But yes, it's better to use classes directly. So long as implemented against an interface of course!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 07:06:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345212#M1992384</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2021-01-04T07:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345213#M1992385</link>
      <description>&lt;P&gt;if you start using Class, forget the static method. There is a place for Abap developper who use it ...  next to Hungarian notation &lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 11:12:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345213#M1992385</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2021-01-04T11:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345214#M1992386</link>
      <description>&lt;P&gt;&lt;STRONG&gt;data(my_instance) = my_class=&amp;gt;get_instance( ).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Otherwise I agree. &lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 11:39:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345214#M1992386</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2021-01-04T11:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345215#M1992387</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/2688/matthew.billingham.html"&gt;Matthew Billingham&lt;/A&gt; What did you want to say by writing:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;data(my_instance) =
my_class=&amp;gt;get_instance( ).&lt;/EM&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Is there a situation where it is better to write a static method than an
instance method?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Hagit&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jan 2021 12:27:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345215#M1992387</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2021-01-10T12:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345216#M1992388</link>
      <description>&lt;P&gt;Exactly that. This is an occasion where a static method is appropriate - when you want to control instantiation in the class. Singleton and factory pattern.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 07:45:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345216#M1992388</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2021-01-11T07:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: When should I write a class instead of a function module?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345217#M1992389</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/2688/matthew.billingham.html"&gt;Matthew Billingham&lt;/A&gt; What do you mean in "Singleton and factory pattern."?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 16:05:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/when-should-i-write-a-class-instead-of-a-function-module/m-p/12345217#M1992389</guid>
      <dc:creator>hagit</dc:creator>
      <dc:date>2021-01-12T16:05:25Z</dc:date>
    </item>
  </channel>
</rss>

