Talk:Singleton

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(This isn't a singleton.)
m
Line 6: Line 6:
  
 
''"In computer engineering, the singleton pattern is a design pattern used to implement the mathematical concept of a singleton, '''by restricting the instantiation of a class to one object'''"''
 
''"In computer engineering, the singleton pattern is a design pattern used to implement the mathematical concept of a singleton, '''by restricting the instantiation of a class to one object'''"''
 +
 +
:Well, the class constructor should be private. That way only the class itself could create another instance. Of course, component based manager are quite useful but you can't prevent that the user create more than one instance. What you can do is to destroy any additional instances in <code>Awake()</code> --[[User:Bunny83|Bunny83]] 04:06, 12 April 2011 (PDT)

Revision as of 11:06, 12 April 2011

Why a new page? Couldn't you just have updated (and possibly renamed) the old AManagerClass page?--KeliHlodversson 05:58, 12 February 2009 (PST)

This isn't a singleton.

This isn't a singleton. It just provides a global access point to a particular instance. You can create several instances of the class. See http://en.wikipedia.org/wiki/Singleton_pattern for details.

"In computer engineering, the singleton pattern is a design pattern used to implement the mathematical concept of a singleton, by restricting the instantiation of a class to one object"

Well, the class constructor should be private. That way only the class itself could create another instance. Of course, component based manager are quite useful but you can't prevent that the user create more than one instance. What you can do is to destroy any additional instances in Awake() --Bunny83 04:06, 12 April 2011 (PDT)
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox