Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > JavaScript > Re: Singleton
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 27 of 30 Topic 35510 of 37128
Post > Topic >>

Re: Singleton

by Lasse Reichstein Nielsen <lrn@[EMAIL PROTECTED] > May 25, 2008 at 03:11 PM

VK <schools_ring@[EMAIL PROTECTED]
> writes:

> On May 25, 3:42 pm, Lasse Reichstein Nielsen <l...@[EMAIL PROTECTED]
> wrote:
>> In a prototype based language, you
>> can create an object directly, so there is no need to introduce
>> an otherwise unnecessary type for a single object.
>
> From a clean pattern point of view it is arguable IMHO. If there is an
> object distinctly different from the generic Object then why not to
> introduce a specific constructor for it? 

How is it different from a generic object? It has properties, and
that's all that really matters. The Math object does fine in this way.
No need for a constructor, because there is no need to construct
any more!

> Besides, the singleton can be the privileged consumer of other
> objects' methods where it would be more convenient to check if
> (Consumer instanceof MySingleton) rather than using some workaround
> checks.

Why check at all? Just call the method and do***ent that objects
passed here should have such a method.
(An it's not like you can't cir***vent the singleton'ness anyway,
if you really want to, or change the properties of the singleton
object).


The problem with the Singleton (anti-)pattern is that it shouldn't
be visible. If it makes sense to have a type, then there is no
reason to restrict to just one instance at the design level.
The implementation might only need one (but experience tells me
that, e.g., testing usually requires alternatives).

The singleton idea combines two concerns into one class: The behavior
of the class and that there should be a single designated instance
that an application should use. 

These two concerns could just as easily be separated into two
cl*****: the class itself and a toolbox/factory class for controlling
instancing.
<URL:http://www.ibm.com/developerworks/webservices/library/co-single.html>

Hmm, guess I'm just rambling against singletons in general.

/L
-- 
Lasse Reichstein Nielsen  -  lrn@[EMAIL PROTECTED]
 DHTML Death Colors:
<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
  'Faith without judgement merely degrades the spirit divine.'
 




 30 Posts in Topic:
Singleton
Ugo <privacy@[EMAIL PR  2008-05-07 10:42:51 
Re: Singleton
Sam -- <noemail@[EMAIL  2008-05-07 14:39:24 
Re: Singleton
Ugo <privacy@[EMAIL PR  2008-05-07 18:14:25 
Re: Singleton
RoLo <rolosworld@[EMAI  2008-05-07 08:06:37 
Re: Singleton
RoLo <rolosworld@[EMAI  2008-05-07 08:08:10 
Re: Singleton
"Richard Cornford&qu  2008-05-21 22:20:21 
Re: Singleton
Ugo <privacy@[EMAIL PR  2008-05-23 16:22:42 
Re: Singleton
Thomas 'PointedEars' Lahn  2008-05-23 20:45:26 
Re: Singleton
"Richard Cornford&qu  2008-05-26 16:19:01 
Re: Singleton
Peter Michaux <petermi  2008-05-23 11:07:58 
Re: Singleton
Ugo <privacy@[EMAIL PR  2008-05-24 17:58:50 
Re: Singleton
"Richard Cornford&qu  2008-05-26 16:18:58 
Re: Singleton
"P. Prikryl" &l  2008-05-23 12:30:40 
Re: Singleton
Thomas 'PointedEars' Lahn  2008-05-23 21:54:35 
Re: Singleton
Peter Michaux <petermi  2008-05-23 12:43:47 
Re: Singleton
VK <schools_ring@[EMAI  2008-05-24 09:13:44 
Re: Singleton
Peter Michaux <petermi  2008-05-24 09:25:50 
Re: Singleton
Ugo <privacy@[EMAIL PR  2008-05-25 00:02:02 
Re: Singleton
VK <schools_ring@[EMAI  2008-05-24 13:31:52 
Re: Singleton
Peter Michaux <petermi  2008-05-24 16:19:51 
Re: Singleton
Ugo <privacy@[EMAIL PR  2008-05-25 09:01:38 
Re: Singleton
"Richard Cornford&qu  2008-05-26 16:19:05 
Re: Singleton
VK <schools_ring@[EMAI  2008-05-25 01:31:38 
Re: Singleton
Lasse Reichstein Nielsen   2008-05-25 13:42:07 
Re: Singleton
Lasse Reichstein Nielsen   2008-05-25 13:52:35 
Re: Singleton
VK <schools_ring@[EMAI  2008-05-25 05:07:35 
Re: Singleton
Lasse Reichstein Nielsen   2008-05-25 15:11:19 
Re: Singleton
VK <schools_ring@[EMAI  2008-05-25 08:35:40 
Re: Singleton
Peter Michaux <petermi  2008-05-25 10:18:55 
Re: Singleton
Peter Michaux <petermi  2008-05-21 21:14:21 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 13:55:18 CDT 2008.