<?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: singleton concept in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220196#M1523726</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;from the [SingletonPattern|http://www.c2.com/cgi/wiki?SingletonPattern] page:&lt;/P&gt;&lt;P&gt;A Singleton is the combination of two essential properties: &lt;/P&gt;&lt;P&gt;1. Ensure a class only has one instance &lt;/P&gt;&lt;P&gt;2. Provide a global point of access to it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABAP does not have built-in support for singletons, so you must enforce the one instance only rule with a private constructor and provide a global access point with a class method like get_instance( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;J.N.N&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Aug 2010 18:32:30 GMT</pubDate>
    <dc:creator>nomssi</dc:creator>
    <dc:date>2010-08-20T18:32:30Z</dc:date>
    <item>
      <title>singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220188#M1523718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i am not sure if i'm perceiving the singleton concept correctly.Please help me in understanding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If i'm not wrong, singleton concept is to make a class have only one object(instance).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and the way you define a class is "CLASS lcl_a DEFINITION CREATE PRIVATE FINAL."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i've done the same but i'm able to create more than one instance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS lcl_a DEFINITION DEFERRED.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    DATA: o_a TYPE REF TO lcl_a,&lt;/P&gt;&lt;P&gt;          o_b TYPE REF TO lcl_a.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      CLASS lcl_a DEFINITION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS lcl_a DEFINITION CREATE PRIVATE FINAL.&lt;/P&gt;&lt;P&gt;  PUBLIC SECTION.&lt;/P&gt;&lt;P&gt;    CLASS-METHODS: m_sta.&lt;/P&gt;&lt;P&gt;    METHODs: m_ins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDCLASS.                    "lcl_a DEFINITION&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      CLASS lcl_a IMPLEMENTATION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS lcl_a IMPLEMENTATION.&lt;/P&gt;&lt;P&gt;  METHOD m_sta.&lt;/P&gt;&lt;P&gt;    CREATE OBJECT o_a.&lt;/P&gt;&lt;P&gt;    CREATE OBJECT o_b.&lt;/P&gt;&lt;P&gt;  ENDMETHOD.                    "class_constuctor&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  METHOD m_ins.&lt;/P&gt;&lt;P&gt;    WRITE: / 'i am the instance method.'.&lt;/P&gt;&lt;P&gt;  ENDMETHOD.&lt;/P&gt;&lt;P&gt;ENDCLASS.                    "lcl_a IMPLEMENTATION&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*CLASS lcl_b DEFINITION.&lt;/P&gt;&lt;P&gt;*ENDCLASS.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;*CLASS lcl_b IMPLEMENTATION.&lt;/P&gt;&lt;P&gt;*ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL METHOD lcl_a=&amp;gt;m_sta.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  o_a-&amp;gt;m_ins( ).&lt;/P&gt;&lt;P&gt;  o_b-&amp;gt;m_ins( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how does singleton concept make sense?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 05:44:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220188#M1523718</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-20T05:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220189#M1523719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 05:54:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220189#M1523719</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-20T05:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220190#M1523720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;lavanya,&lt;/P&gt;&lt;P&gt;thanks for the quick reply, but, this was not i was looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in your METHOD get_apps_instance. if you have not specified that IF CONDITION you can create another instance right?so, how does the singleton concept make sense?&lt;/P&gt;&lt;P&gt;    IF lo_apps IS INITIAL.&lt;/P&gt;&lt;P&gt;      CREATE OBJECT lo_apps.&lt;/P&gt;&lt;P&gt;      ro_apps = lo_apps.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or is it that singleton concept is, you CAN create multiple objects.but you have to restrict it to only one?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tHANKS,&lt;/P&gt;&lt;P&gt;zID.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 06:18:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220190#M1523720</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-20T06:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220191#M1523721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;  As developer/owner of the CLASS you can create as many instances as you want( inside the methods of the CLASS), but others who are using your CLASS cannot create multiple instances, they have to call static methods of your CLASS to get object instance. So it is up to you to restrict the no.of instances of your CLASS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 06:47:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220191#M1523721</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-20T06:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220192#M1523722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 07:02:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220192#M1523722</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-20T07:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220193#M1523723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Phani, &lt;/P&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, i still can't digest the justification of this pattern.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it's just that instead of using CREATE OBJECT, one has to just call the static method to create the instance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the definition of SINGLEton classes should rather have been like... "you can create as many instances as possible,but, only inside the class" or "you can restrict the user from creating the objects using CREATE OBJECT"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i should say the definition is completely unjustified provided what you are saying is correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;anyway&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Zid.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 07:19:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220193#M1523723</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-20T07:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220194#M1523724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 07:35:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220194#M1523724</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-20T07:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220195#M1523725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Zid,&lt;/P&gt;&lt;P&gt;we use singleton concept if only one instance of a CLASS has to created and all actions has to be performed only on that instance. if user calls a static method multiple times to get the instance , you will first check if object is created or not, if its not created then you will create a new one and save it in class variable and return the same instance reference very time the method is called. So for outside users of the class its a singleton bcoz the same instance is returned from method. But inside the class there is no restriction that only one instance can be created inside methods of the same class. Good practice is we create one instance and use it in all methods.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Phani&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 08:21:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220195#M1523725</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-20T08:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220196#M1523726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;from the [SingletonPattern|http://www.c2.com/cgi/wiki?SingletonPattern] page:&lt;/P&gt;&lt;P&gt;A Singleton is the combination of two essential properties: &lt;/P&gt;&lt;P&gt;1. Ensure a class only has one instance &lt;/P&gt;&lt;P&gt;2. Provide a global point of access to it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABAP does not have built-in support for singletons, so you must enforce the one instance only rule with a private constructor and provide a global access point with a class method like get_instance( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;J.N.N&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 18:32:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220196#M1523726</guid>
      <dc:creator>nomssi</dc:creator>
      <dc:date>2010-08-20T18:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220197#M1523727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this can be solved by using Static Constructor instead of using Static Method. which executed only once in life time of a class.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Aug 2010 09:47:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220197#M1523727</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-23T09:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220198#M1523728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Change your method:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHOD m_sta.
  IF o_a IS NOT BOUND.
    CREATE OBJECT o_a.
  ENDIF.
ENDMETHOD. "class_constuctor&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, no matter what you do, you'll only have one instance of your class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The way I normally do it however is to define a static public method (factory) that returns a reference of &lt;EM&gt;TYPE REF TO myclass&lt;/EM&gt;, and have a static attribute that is &lt;EM&gt;TYPE REF TO myclass.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHOD factory. " Note this is static public method
  IF myclass=&amp;gt;my_object IS NOT BOUND.
    CREATE OBJECT myclass=&amp;gt;my_object.
  ENDIF.
  r_obj = myclass=&amp;gt;my_object.
ENDMETHOD.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use it like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA lr_obj TYPE REF TO myclass.

lr_obj = myclass=&amp;gt;factory( ).
lr_obj-&amp;gt;do_stuff( ). " Do_stuff being an instance method of myclass &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Aug 2010 14:34:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220198#M1523728</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2010-08-23T14:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220199#M1523729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt; I think this can be solved by using Static Constructor instead of using Static Method. which executed only once in life time of a class.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Yep, I would support vidyasagar's suggestion. I'm generally using singleton patterns with help of the &lt;STRONG&gt;CLASS_CONSTRUCTOR&lt;/STRONG&gt;, too. This ensures that only one instance of an object exists. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, &lt;/P&gt;&lt;P&gt;Alej&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Aug 2010 20:43:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220199#M1523729</guid>
      <dc:creator>alejiandro_sensejl</dc:creator>
      <dc:date>2010-08-23T20:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220200#M1523730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The reason to use a factory method, rather than the class constructor, is that instantiation as soon as the class is touched in anyway, isn't always desirable. For example, if there are other static methods that don't use an instance, and instantiation has a significant overhead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Aug 2010 07:27:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220200#M1523730</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2010-08-24T07:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220201#M1523731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Matt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Got your point on CLASS_CONSTRUCTOR v/s FACTORY method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just FACTORY method is used in classes with private instantiation. I don't think using this method makes any sense with public instantiation. Your comments ?&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>Tue, 24 Aug 2010 07:41:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220201#M1523731</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-08-24T07:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220202#M1523732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have a factory method in a class with public instantiation, then that simply allows two different ways of creating instances. I can't think of a reason why you'd want to do this; it does seem to go rather against OOP principles.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Aug 2010 10:04:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220202#M1523732</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2010-08-24T10:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220203#M1523733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Matt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the decision between CLASS_CONSTRUCTOR and a factory pattern should depend on the usage of the class. &lt;/P&gt;&lt;P&gt;If I have a tool class (e.g. for handling an ALV) I would favor the class constructor, but if I have a object representing e.g. a business object (like orders, notifications, etc.) I would use a factory pattern to allow only one instance per business object. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would also recommend to avoid the use of static methods, because they can't be redefined.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Alej&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Aug 2010 21:40:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220203#M1523733</guid>
      <dc:creator>alejiandro_sensejl</dc:creator>
      <dc:date>2010-08-24T21:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220204#M1523734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; I would also recommend to avoid the use of static methods, because they can't be redefined.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Regards,&lt;/P&gt;&lt;P&gt;&amp;gt; Alej&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'd put it a bit stronger than that. When I've found that I've needed to redefine a static method, it's meant I've got the design wrong.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Aug 2010 05:50:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220204#M1523734</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2010-08-25T05:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220205#M1523735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;guys...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sorry for the late reply...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so...what i can infer from this thread is that...&lt;/P&gt;&lt;P&gt;It's not that you can not create multiple instances using singleton concepts...it's just that you should restrict the user from creating multiple...may it be using static constructor...or using the factory method ..or a static method (with an IF condition)....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or is it, as someone said, that SAP has not adopted the singleton concept properly? i do not know how it works in java though...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks guys,&lt;/P&gt;&lt;P&gt;Zid.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Aug 2010 09:15:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220205#M1523735</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-25T09:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220206#M1523736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've just encountered another scenario where you wouldn't want to use a CLASS-CONSTRUCTOR:  When the code you want to execute needs to raise an exception to be trapped by the caller. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; guys...&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; sorry for the late reply...&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; so...what i can infer from this thread is that...&lt;/P&gt;&lt;P&gt;&amp;gt; It's not that you can not create multiple instances using singleton concepts...it's just that you should restrict the user from creating multiple...may it be using static constructor...or using the factory method ..or a static method (with an IF condition)....&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; or is it, as someone said, that SAP has not adopted the singleton concept properly? i do not know how it works in java though...&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Thanks guys,&lt;/P&gt;&lt;P&gt;&amp;gt; Zid.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The singleton concept is a &lt;EM&gt;[design pattern|http://en.wikipedia.org/wiki/Design_pattern_(computer_science)]&lt;/EM&gt;. If you need to ensure that only ever one instance exists, then you implement your class using the &lt;EM&gt;singleton pattern&lt;/EM&gt;. It's not something that's built into a language. In Java, you have to implement it yourself. There's no concept of defining a class as a singleton within the code. So, it's nothing to do with SAP "not adopting it properly."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[From the wikipedia article:|http://en.wikipedia.org/wiki/Singleton_pattern]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The singleton pattern is implemented by creating a class with a method that creates a new instance of the class if one does not exist. If an instance already exists, it simply returns a reference to that object. To make sure that the object cannot be instantiated any other way, the constructor is made protected (not private, because reuse and unit test could need to access the constructor). Note the distinction between a simple static instance of a class and a singleton: although a singleton can be implemented as a static instance, it can also be lazily constructed, requiring no memory or resources until needed.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The article shows that the &lt;EM&gt;laziest&lt;/EM&gt; implementation is that using a factory method.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Aug 2010 10:52:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220206#M1523736</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2010-08-25T10:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: singleton concept</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220207#M1523737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's not something that's built into a language. &lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Patterns might be  [supported by the language|http://www.c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatures], e.g. JavaScript and [Scala|http://en.wikipedia.org/wiki/Singleton_pattern#Scala] have native support for singletons. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A word of caution: [SingletonsAreGood|http://www.c2.com/cgi/wiki?SingletonsAreGood] and [SingletonsAreEvil|http://www.c2.com/cgi/wiki?SingletonsAreEvil] !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;J.N.N.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Aug 2010 23:05:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/singleton-concept/m-p/7220207#M1523737</guid>
      <dc:creator>nomssi</dc:creator>
      <dc:date>2010-08-26T23:05:51Z</dc:date>
    </item>
  </channel>
</rss>

