aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Replacing Singleton Design Pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Replacing Singleton Design Pattern" Watch "Replacing Singleton Design Pattern" New topic
Author

Replacing Singleton Design Pattern

Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
Hello Friends,

Can we replace singleton design pattern by making all the methods of the class as static and declaring all the constructors as private. This way other classes won't be able to instantiate this class and have to invoke methods using class name only. Also which approach will be better performance wise?

thanks


Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

.
Can we replace singleton design pattern by making all the methods of the class as static and declaring all the constructors as private.


Yes you replace singleton by making all methods static. I don't see any performance gain using static methods. I am more comfortable using singleton rather than all-methods-static class implementation even though there is no harm using the latter.


Groovy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Replacing Singleton Design Pattern