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

Former Member
0 Likes
628

Hi all,

Any body please provide me information on singleton class and how can we created them in ABAP.

Thanks.

Anil.

4 REPLIES 4
Read only

Sm1tje
Active Contributor
0 Likes
545

A singleton class is a class that cannot be instantiated more than once (in a single program that is). Of course you can do the same in other programs without facing any problems. You can do this by setting the flag final and create the class as private. Now the class can only be instantiated in one of its own methods.

I can't really think of a real life example in which you want to make sure that a class is only instantiated once.

Read only

Former Member
0 Likes
545

I have a real life example. If getting married is your objective (Class), better it gets instatiated only once. Else it could land you in a lot of trouble

Read only

Clemenss
Active Contributor
0 Likes
545

Hi Anil,

is this an exam question? (looks like...)

[singleton class and how can we created them in ABAP|http://www.google.es/#hl=en&source=hp&q=singletonclassandhowcanwecreatedtheminABAP&btnG=GoogleSearch&aq=f&oq=singletonclassandhowcanwecreatedthemin+ABAP&fp=1&cad=b]

Regards,

Clemens

Read only

Former Member
0 Likes
545

Hi,

See following blog. It has all details about singlton.

http://help-abap.blogspot.com/2008/09/abap-object-design-patterns-singleton.html

rgds,

PB