wood burning stoves
The moose likes Java in General and the fly likes Parameters VS Singleton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Parameters VS Singleton" Watch "Parameters VS Singleton" New topic

Parameters VS Singleton

Derek White

Joined: Jul 24, 2008
Posts: 14
Hello everyone

I've been writing some applications in Java lately and now face a slight conundrum regarding parameterized constructors and singleton patterns.

- The two classes I refer to, UpdateManager and Settings, reside in the same package.
- I need to access what should be a single, program-wide instance of Settings from UpdateManager
- Settings will be modified from some dialog outside of the package
- UpdateManager will be used from some frame outside of the package

I do not understand which programming style would be better in this case. Should I pass in a Settings object as an argument in UpdateManager's constructor even though there should always be only instance of Settings at any given time?

What are the pros and cons of parameterization? Singleton patterns?

Is it just preference?

It would be really helpful if someone could explain some situation where either style might lead to an unseen problem.

Thanks a lot!
Derek White

Joined: Jul 24, 2008
Posts: 14
I actually found some really great articles:

http://www.codingwithoutcomments.com/ (top post)
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Parameters VS Singleton
It's not a secret anymore!