![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
comp.lang.javascript archiveRe: A Singleton with Inheritance
From: Lasse Reichstein Nielsen <lrn@hotpop.com>
Date: Fri Dec 09 2005 - 02:49:24 CET
Kevin Newman <CaptainN@unFocus.com> writes:
> I have been playing around with a couple of ways to add inheritance to
Does the singleton (anti-)pattern make sense at all in a prototype based
In a class based language, a singleton is a type for which there is
In a prototype based language, there are no classes and no
> As far as I'm aware, using an anonymous constructor to create a
While this creates an object with a prototype different from
> Here are two ways to create a singleton with inheritance:
So we restrict ourselves to constructors that can be seen as
> // second way
> singletonObj = (function() {
Here the singletonObj uses an instance of SuperClass as its prototype.
Notice that this is not similar to class based inheritance, where
Again I fail to see the advantage over
It is impossible to enforce the singleton pattern, since you can
function clone(o) {
notSoSingletonObj = clone(singletonObj);
/L
-- Lasse Reichstein Nielsen - lrn@hotpop.com DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.'Received on Sun Dec 11 14:34:24 2005 |