Re: PHP 4.0 Bug #2675 Updated: Misbehavior of object initializers
| From: | ZeroDiVide | Date: | Sun, 07 Nov 1999 21:41:48 +0000 |
| Subject: | Re: PHP 4.0 Bug #2675 Updated: Misbehavior of object initializers | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-12199@lists.php.net to get a copy of this message | ||
> > > You should use the Factory design pattern I suppose. How about the
> > following:
> > >
> > > And then do something like (actually it doesn't even need to be
> > > $new_db = DB::Factory('mysql');
I had to check some references, but in java or other oop languages where
the "factory" design pattern are used the object instaciator actually is
completly overloading which is thecnically a "feature" of those languages
vs c++.
> > >So i guess the larger question here is are we doing java symantics or
> >c++ ?
>
> PHP semantics :) I'm not sure what you can do in Java with constructors,
> but in this case, PHP is similar to C++.
Is there a design paper or anything that shows where things are headed
with the oop side of things?
> No it isn't. The point of overloading a constructor is to initialize the
> object ($this) with whatever default values you want. If you're doing
> inheritance and you need a new constructor for the offspring class, you
> might want to call the parent's constructor in addition to the added code
> of your new constructor. It's up to the developer to decide what exactly he
> wants to do.
Right but wouldn't it be easy to have the function default to returning
$this and if you don't want to or you want to polymorph into something
else you'll return a different object reference or whatever you'd like.
--------------------------------------------------------------------------------
| Jason "ZeroDiVide" Orcutt "Code is life is Code" |
| Prometheus Project - http://prometheus.zerodivide.net
|
--------------------------------------------------------------------------------