‎2014 Oct 06 3:59 PM
Hi Team,
Can you please explain about singleton class and when we will use singleton class in OO ABAP.
Thanks
Hemasagar.
‎2014 Oct 06 4:27 PM
Often, there is a requirement that you would want to create only one instance of the class. To put it in other words, you do not want any one to create instance of the class if already created.
‎2014 Oct 07 9:26 PM
Hello Kosuru,
in the ABAP Unit Wiki there is a page with some basic explanation of the Singleton pattern.
UnitSu.GoF.Singleton Pattern - ABAP Development - SCN Wiki
Hope this helps
Klaus
‎2015 Jul 16 7:45 AM
Hi Hemasagar,
The concept of restricting the instantiation of the a class to one object is called Singleton.
As name suggests, it will restrict to create only one instance of a class.
Singleton is OO design Pattern. When you implement this pattern in the class it becomes Singleton Class.The usage of this singleton design pattern is purely based on your requirement. For example in a program if your logic is inside a loop and you are creating the object in a loop. Here you can make you use of the singleton design pattern to restrict it to create more than one object.
Regards,
Thiru
‎2015 Jul 16 9:42 AM
Hi Hemasagar Kosuru,
Sometime's we need only one instance for a class at that time, we go for singleton concept in ABAP objects.
Thanks and regards,
B.Umayaraja