When you do things right, people won't be sure you've done anything at all.
Janeice DelVecchio wrote:I make no assertions that the Singleton pattern should or should not be used in practice.
Jyotika Kapoor wrote:i agree to what you say , just wanted to know why singleton pattern is required at all when we can achieve the same through static.
Jyotika Kapoor wrote:
Have this small doubt The Single Pattern ; helps in creating a single object which will be shared among different classes , the static variable can be used to achieve this, then why do we a singleton pattern at all , i mean if its just about one copy across the classes.
Ulrika Tingle wrote:Singleton probably is more motivated in a language like C++ than Java.
But I'd say in Java you use a Singleton for the same reason you use getter/setter methods. It provides a thin abstraction over accessing "naked" variables. Whether you want this abstraction or even need it is up to you. Nobody forces you to use setter/getter methods and nobody forces you to use a Singleton.
Pat Farrell wrote:While nobody should force you to use a Singleton pattern in Java, if you work for me, I'll force you to not use it, as its bad engineering.
Some will argue that this is a religious argument, and so I'll stop here since this is "Beginning Java" but I think its an engineering argument.
When you do things right, people won't be sure you've done anything at all.
Janeice DelVecchio wrote:[...] how do you manage the possibilities that someone might try to instantiate it again without using a singleton pattern?
Janeice DelVecchio wrote:I'm just asking, and I don't wanna stir up any arguments here....
Janeice DelVecchio wrote:
If you have lots of people that are programming pieces of an application that all use something that has to be instantiated only one time (say a timer, or the post office, et cetera), how do you manage the possibilities that someone might try to instantiate it again without using a singleton pattern?
Pat Farrell wrote:
While nobody should force you to use a Singleton pattern in Java, if you work for me, I'll force you to not use it, as its bad engineering.
John de Michele wrote:Janeice:
One way to control object creation would be to create a factory class. Instead of instantiating objects of the target class directly, you would call a method from the factory class to get object references. The factory could then internally control whether or not you got a reference to a new object or an existing one.
John.
When you do things right, people won't be sure you've done anything at all.
When you do things right, people won't be sure you've done anything at all.
James Clarks wrote:The infamous Simpleton design pattern is a non-object-oriented way to write "structured" procedural code. It is typically used by programmers that either do not significantly understand object-oriented design principles or are lazy buffoons that don't care about the code they write.
This pattern should never have been included in the GOF book, and was simply a bone to get individuals to start to think about patterns period.
Just me two cents
When you do things right, people won't be sure you've done anything at all.
Janeice DelVecchio wrote:Alright, I'm now trying to figure out if this argument has any documentation either way.
likewise for resons to use them.
If the singleton is so bad, why do they still teach it to students in programming/design classes?
When you do things right, people won't be sure you've done anything at all.
If the singleton is so bad, why do they still teach it to students in programming/design classes?
David Newton wrote:@Janeice: I'm not sure how you read the main hits to that and came away with Singletons being a < JDK 1.5 problem, maybe you could elaborate?
When you do things right, people won't be sure you've done anything at all.
"The" problem? What do you think "the" problem is?
When you do things right, people won't be sure you've done anything at all.
Jeff Storey
Software Developer
[url]http://jeffastorey.blogspot.com[/url]
Janeice wrote:you couldn't tell me anything except "google 'singleton considered stupid.'
When you do things right, people won't be sure you've done anything at all.
When you do things right, people won't be sure you've done anything at all.
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|