Re: new overloading feature?
| From: | Derrell dot Lipman at UnwiredUniverse dot com | Date: | Sat, 06 Nov 2004 01:51:27 +0000 |
| Subject: | Re: new overloading feature? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-13745@lists.php.net to get a copy of this message | ||
cm@leetspeak.org writes:
> I don't think it's "really clean" to not return a *new* instance with a
> *new* call. I'm not sure what kind of advantage it gives you over a private
> constructor and a static getInstance($n) function.
"Really clean" in that I believe that it's the class' business what it returns.
If the class wants to be a singleton, the user of the class doesn't even need
to know it is getting the same object returned each time it asks for a "new"
one. If the class wants to return a pre-existing object in some cases but a
newly-allocated object in other cases, I believe that's up to the class, not
to the caller. That is a characteristic of the design of the class. (I can
envision alternative viewpoints, however. :-)
Given my viewpoint, letting the caller request a "new" object each time (when
in fact the class intentionally -- sometimes or always -- returns a pre-
existing object because that's the design of the class), seems clean.
Two responses, two negatives. Ok, I withdraw the request. :-) I will not
belabor the point further, but will be glad to discuss the merits of this and
its implementation if any one else feels it could be a useful feature.
Cheers,
Derrell