<?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: OOPS  question in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289323#M1989255</link>
    <description>&lt;P&gt;Well there is even an abapOpenCheck for that which cites the language help:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.abapopenchecks.org/checks/90/" target="test_blank"&gt;https://docs.abapopenchecks.org/checks/90/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I can't really rememeber where I encountered that problem ~5 years ago. But changing constructor visibility back to default public solved that.&lt;/P&gt;</description>
    <pubDate>Mon, 09 Nov 2020 19:46:13 GMT</pubDate>
    <dc:creator>BiberM</dc:creator>
    <dc:date>2020-11-09T19:46:13Z</dc:date>
    <item>
      <title>OOPS  question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289319#M1989251</link>
      <description>&lt;P&gt;how to call the instance construct that is declared in the private section of the class. &lt;/P&gt;
  &lt;P&gt;class abc definition. &lt;/P&gt;
  &lt;P&gt;private section. &lt;/P&gt;
  &lt;P&gt;methods constructor. &lt;/P&gt;
  &lt;P&gt;endclass. &lt;/P&gt;
  &lt;P&gt;how to call the above constructor?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 17:38:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289319#M1989251</guid>
      <dc:creator>former_member514536</dc:creator>
      <dc:date>2020-11-09T17:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: OOPS  question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289320#M1989252</link>
      <description>&lt;P&gt;Beside the fact that a constructor for technically reasons should never be declared Private, your class probably has another static (class-) Method that handles instance creation. &lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 17:47:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289320#M1989252</guid>
      <dc:creator>BiberM</dc:creator>
      <dc:date>2020-11-09T17:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: OOPS  question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289321#M1989253</link>
      <description>&lt;P&gt;i know that construct should never be private. But how to answer the above question. it was faced in an interview &lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 18:21:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289321#M1989253</guid>
      <dc:creator>former_member514536</dc:creator>
      <dc:date>2020-11-09T18:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: OOPS  question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289322#M1989254</link>
      <description>&lt;P&gt;&lt;EM&gt; a constructor for technically reasons should never be declared Private&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Really? What would they be? That's not even a philosophy I've heard of.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 18:23:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289322#M1989254</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2020-11-09T18:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: OOPS  question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289323#M1989255</link>
      <description>&lt;P&gt;Well there is even an abapOpenCheck for that which cites the language help:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.abapopenchecks.org/checks/90/" target="test_blank"&gt;https://docs.abapopenchecks.org/checks/90/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I can't really rememeber where I encountered that problem ~5 years ago. But changing constructor visibility back to default public solved that.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 19:46:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289323#M1989255</guid>
      <dc:creator>BiberM</dc:creator>
      <dc:date>2020-11-09T19:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: OOPS  question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289324#M1989256</link>
      <description>&lt;P&gt;It actually makes sense to make the constructor private if you are using a creational design pattern; such as:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Builder&lt;/LI&gt;&lt;LI&gt;Factory&lt;/LI&gt;&lt;LI&gt;Singleton&lt;/LI&gt;&lt;LI&gt;Multiton&lt;/LI&gt;&lt;LI&gt;...&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;In such cases, the class will typically have a public static method which is responsible of creating an instance. You will call this static public method to create the object instance, instead of calling the constructor.&lt;/P&gt;&lt;P&gt;Check the following example class: &lt;A href="https://github.com/keremkoseoglu/addict/blob/main/src/ycl_addict_data_element.clas.abap" target="_blank"&gt;https://github.com/keremkoseoglu/addict/blob/main/src/ycl_addict_data_element.clas.abap&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This is how you create the object:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(my_obj) = ycl_addict_data_element=&amp;gt;get_instance( 'BUKRS' ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Instead of this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(my_obj) = NEW ycl_addict_data_element( 'BUKRS' ). " ERROR!&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;See?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 05:07:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289324#M1989256</guid>
      <dc:creator>keremkoseoglu</dc:creator>
      <dc:date>2020-11-10T05:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: OOPS  question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289325#M1989257</link>
      <description>&lt;P&gt;&amp;gt;&amp;gt; how to call the above constructor?&lt;/P&gt;&lt;P&gt;Since this is an interview question, which is more about object oriented programming in general than specifically about SAP OO, the answer should be, the following:&lt;/P&gt;&lt;P&gt;In order to create an object of a class with a private constructor, the class needs to have, for example, a public static method which is able to create the object. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;class abc definition.
  public section.
    methods create_instance. " method implementation will contain private constructor
  private section.
    methods constructor.
endclass.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Nov 2020 05:37:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/oops-question/m-p/12289325#M1989257</guid>
      <dc:creator>michael_piesche</dc:creator>
      <dc:date>2020-11-10T05:37:14Z</dc:date>
    </item>
  </channel>
</rss>

