Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

singleton class in OO ABAP

Former Member
0 Likes
2,161

Hi Team,

Can you please explain about singleton class  and when we will use singleton class in OO ABAP.

Thanks

Hemasagar.

4 REPLIES 4
Read only

former_member156446
Active Contributor
0 Likes
1,070

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.

http://wiki.scn.sap.com/wiki/display/ABAP/SINGLETON+CLASSES

Read only

former_member183804
Active Contributor
0 Likes
1,070

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


Read only

thirus11
Participant
0 Likes
1,070

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

Read only

Former Member
0 Likes
1,070

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