1. controls access to a single instance of the class
2. Reduces name space usage
3. Permits refinement of operations and representation.
4. Permits a variable number of instances
5. Is more flexible than class methods (operations)
1. easy to understand
2. OK, if you think it's a benefit.
3. I don't get it. Are they talking about it's better to use a specific method to get an instance than use new method??
4. As far as I know, Singleton means one instance, only one. Number of instances?? What are they talking about?
5. Again, I don't understand what kind of class methods(operations)?
Generally, although I had read Head First Design Pattern, I found it's a little bit hard for me to understand the benefits (P282~284). I knew a lot of people here recommended this book. When you read this part, did you have the same feeling like me?
I heard the new SCEA test is based on scenario question. If the real testing questions like this, I think it will not be easy for me to pass it.
Could anyone give me some suggestions?
Thanks in advance.
I knew a lot of people here recommended this book
When it comes to design patterns I see no point in using this book. The points you list are lifted verbatim from the original GoF text on the Singleton pattern. I'd strongly recommend getting hold of a copy.
Permits refinement of operations and representation
You can subclass a Singleton and easily configure an applicate to use it in place of its parent.
As far as I know, Singleton means one instance, only one. Number of instances?? What are they talking about?
They're talking about the fact you can easily modify Singleton to permit the existence of more than instance. For example, a Singleton could maintain a pool of itself and control access to that pool through the same getInstance() method; clients would be none the wiser (although technically it would no longer be a Singleton).
Is more flexible than class methods (operations)
You can't override static methods
What this all boils down to is the fact it's better to use an object as opposed to static methods with regards to the kinds of problems Singleton addresses.