Hey,
having parameters in a singleton is against the pattern in general. Imagine a 
simple scenario:

// some place
var a = Singleton.getInstance(1,2);  // returns a configured singleton with 1 
and 2

// ...
// some other place
var b = Singleton.getInstance(2,1); // what should it return? A new instance 
configured with the new parameter or the old one and ignore the parameter?

You see, it is some kind of a problem here because you would either have more 
than one instance or ignore the second set of parameters. 

If you think that one of the both suggested ways is exactly what you need, you 
can still configure your class the way you want with a own getInstance method.
But from a software development point of view, I would really not recommend 
that.

Regards,
Martin


Am 05.01.2011 um 17:41 schrieb dimitri:

> 
> Hello,
> 
> I'm french so sorry for my english !
> 
> I would like to create a singleton class with parameters.
> 
> For example : general.Form1.getInstance(param1, param2);
> 
> In the constructor of Form1 i have :
> 
>       construct : function(param1, param2) {
>               this.base(arguments, param1, param2);
>       },
> 
> But param1 and param2 are already empty. 
> 
> How can i pass paramaters when i create or get my singleton ???
> 
> Thanks
> -- 
> View this message in context: 
> http://qooxdoo.678.n2.nabble.com/Singleton-getInstance-with-parameters-tp5892532p5892532.html
> Sent from the qooxdoo mailing list archive at Nabble.com.
> 
> ------------------------------------------------------------------------------
> Learn how Oracle Real Application Clusters (RAC) One Node allows customers
> to consolidate database storage, standardize their database environment, and, 
> should the need arise, upgrade to a full multi-node Oracle RAC database 
> without downtime or disruption
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to