Constructors as factory methods
| From: | Mika Tuupola | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Constructors as factory methods | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-1565@lists.php.net to get a copy of this message | ||
Is there any concensus on can a class constructor act as
a factory method?
For example if I have a classes Car Car_Lada and Car_Porche,
I would like to make the constructor return the concrete
class like:
$c = new Car("Lada")
instead of using
c= new Car::Factory("Lada")
However looking at other PEAR classes they all use a static
factory method call to return the concrete object. Which way
is preferred?
--
Mika Tuupola http://www.appelsiini.net/~tuupola/