<?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: Local Classes within Global Classes in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514579#M1853469</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Justin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I personally try to follow the recommedation that an object shall have a clear responsibility and try to avoid multi purpose classes. If a private method fits to the purpose of the class I create a private method. In case the new functionality does not fit well to class I prefer to move it to a different class. (There exists lot of proof that this is not the 100% case).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Classes with a single responsibility are easier to test which is a benefit for instance. On the other hand having lots of global classes make it hard to find out the key concepts in SE80 for me. Therefore I like to move helper classes with limited liklyhood for reuse in local classes. This makes life easier for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp; Klaus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Oct 2014 18:08:07 GMT</pubDate>
    <dc:creator>former_member183804</dc:creator>
    <dc:date>2014-10-06T18:08:07Z</dc:date>
    <item>
      <title>Local Classes within Global Classes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514573#M1853463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have been reviewing the Official ABAP Programming Guidelines (SAP Press) and a point was made with regard to local classes within global classes.&amp;nbsp; The point, if there is functionality/processing required within a global class that is only needed by that class it could make sense to create a local class within to handle this unique processing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question... Is there an advantage (or disadvantage for that matter) to creating an included local class instead of creating a private method for the same purpose?&amp;nbsp; It would seem to require more effort on the front end of the class development to create an additional local class to handle some specific processing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Justin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Aug 2014 20:01:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514573#M1853463</guid>
      <dc:creator>jdloranger</dc:creator>
      <dc:date>2014-08-18T20:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: Local Classes within Global Classes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514574#M1853464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;Is there an advantage (or disadvantage for that matter) to creating an included local class instead of creating a private method for the same purpose?&lt;/P&gt;


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I can share my experience on defining local classes within global classes (excluding the ABAP unit classes).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H4&gt;Requirement:&lt;/H4&gt;&lt;P&gt;We had to enhance a transaction to display a pop-up with data in tabular form &amp;amp; the user had to select one entry to continue processing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H4&gt;Solution:&lt;/H4&gt;&lt;P&gt;Relevant BAdI was implemented and it was decided that the screen will be designed as an ALV popup. So in the BAdI implementation class i defined a local class &amp;amp; delegated all the ALV handling activities to it. My rationale behind this design was that the BAdI class is not responsible for handling the ALV &amp;amp; their "concerns" are different! Hence the ALV must be handled in a different class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could have created a global class for this, but i thought that BAdI &amp;amp; the ALV-popup are too tightly coupled. So i decided to use a local class within the BAdI implementation class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Aug 2014 21:01:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514574#M1853464</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2014-08-18T21:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Local Classes within Global Classes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514575#M1853465</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Justin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I liked Suhas answer for this (unfortunately unusual) good question. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My answer is that there is not a clear advantage per se; it will depend on your use case. Another use case is to create an local exception class, as I show: &lt;A __default_attr="83667" __jive_macro_name="blogpost" class="jive_macro jive_macro_blogpost" data-orig-content="Local exception class in global class - the trick" href="https://community.sap.com/"&gt;&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I believe most of the times private methods will do the trick.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Custodio&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Aug 2014 00:24:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514575#M1853465</guid>
      <dc:creator>custodio_deoliveira</dc:creator>
      <dc:date>2014-08-19T00:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Local Classes within Global Classes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514576#M1853466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I use local classes when I need something doing that can be encapsulated, but tightly linked to the main class. If it isn't tightly linked, then I'll use a global class. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you use a private method to achieve the same, without creating another class, then you are not encapsulating the complexity. This may or may not be the correct approach. It depends on what you're trying to do.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Aug 2014 05:18:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514576#M1853466</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2014-08-19T05:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Local Classes within Global Classes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514577#M1853467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd say that clean separation of concerns is always an advantage in itself, even if the "external" reuse of the locally implemented functionality is not (yet) intended. The main advantage lies IMO in the clarity and structure of the code and, even more importantly, the number of "roles" the global class itself plays/covers (even if only privately) is thereby reduced. It may be an illusory advantage, but it should also considerably ease re-factoring efforts should the external reuse become necessary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;&lt;P&gt;Jānis&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Aug 2014 06:31:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514577#M1853467</guid>
      <dc:creator>Private_Member_7726</dc:creator>
      <dc:date>2014-08-19T06:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Local Classes within Global Classes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514578#M1853468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all.&amp;nbsp; So to summarize...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Depends on what needs to be accomplished by the main class in the first place.&lt;/LI&gt;&lt;LI&gt;Maintain SOC when the required process is tightly bound to the main class.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clearly there is no "one size fits all" answer. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Aug 2014 12:43:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514578#M1853468</guid>
      <dc:creator>jdloranger</dc:creator>
      <dc:date>2014-08-19T12:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Local Classes within Global Classes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514579#M1853469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Justin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I personally try to follow the recommedation that an object shall have a clear responsibility and try to avoid multi purpose classes. If a private method fits to the purpose of the class I create a private method. In case the new functionality does not fit well to class I prefer to move it to a different class. (There exists lot of proof that this is not the 100% case).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Classes with a single responsibility are easier to test which is a benefit for instance. On the other hand having lots of global classes make it hard to find out the key concepts in SE80 for me. Therefore I like to move helper classes with limited liklyhood for reuse in local classes. This makes life easier for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp; Klaus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 18:08:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514579#M1853469</guid>
      <dc:creator>former_member183804</dc:creator>
      <dc:date>2014-10-06T18:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Local Classes within Global Classes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514580#M1853470</link>
      <description>&lt;P&gt;Can we say : Private method of the class can be accessible making friend of the class but not local class methods can accessible outside ? So if requirement is strictly bound to particular class we can use local class in global class .&lt;/P&gt;</description>
      <pubDate>Sun, 28 Apr 2019 11:46:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/local-classes-within-global-classes/m-p/10514580#M1853470</guid>
      <dc:creator>former_member327594</dc:creator>
      <dc:date>2019-04-28T11:46:59Z</dc:date>
    </item>
  </channel>
</rss>

