Talk:Singleton

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 2: Line 2:
  
 
A force that encourages me to have a singleton is when I'd otherwise have to list it as an argument in heaps and heaps of method calls. I think low code verbosity should be considered as a force that would encourage use of certain patterns. [[User:Lindsay|Lindsay Kay]]
 
A force that encourages me to have a singleton is when I'd otherwise have to list it as an argument in heaps and heaps of method calls. I think low code verbosity should be considered as a force that would encourage use of certain patterns. [[User:Lindsay|Lindsay Kay]]
 +
 +
Hmmm... When dealing with singletons in an inheritance hierarchy, [[DBC]] applies. I.e. if the superclass is a singleton it forces all other subclasses to comply (be singletons also); however turning a subclass into a singleton only imposes this on the subclass (and its subclasses)... I found that to be an interesting thought. Do you agree? Or is it completely obvious? Also, if you wish to subclass, due to class encapsulation you have to make the constructor protected. This breaks the singleton pattern as it is then technically possible to instantiate multiple instances within the same package. --[[User:Matthew Harward|Matthew Harward]] 23:35, 4 August 2009 (UTC)

Revision as of 23:35, 4 August 2009

Created the page. --Elliot Fisher 01:41, 19 September 2008 (UTC)

A force that encourages me to have a singleton is when I'd otherwise have to list it as an argument in heaps and heaps of method calls. I think low code verbosity should be considered as a force that would encourage use of certain patterns. Lindsay Kay

Hmmm... When dealing with singletons in an inheritance hierarchy, DBC applies. I.e. if the superclass is a singleton it forces all other subclasses to comply (be singletons also); however turning a subclass into a singleton only imposes this on the subclass (and its subclasses)... I found that to be an interesting thought. Do you agree? Or is it completely obvious? Also, if you wish to subclass, due to class encapsulation you have to make the constructor protected. This breaks the singleton pattern as it is then technically possible to instantiate multiple instances within the same package. --Matthew Harward 23:35, 4 August 2009 (UTC)

Personal tools