Re: Preferred method for using factory pattern
| From: | Martin Jansen | Date: | Fri, 21 Feb 2003 11:05:53 +0000 |
| Subject: | Re: Preferred method for using factory pattern | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-13537@lists.php.net to get a copy of this message | ||
On Thu Feb 20, 2003 at 04:0343PM +0100, Demian Turner wrote:
> What is the preferred method within PEAR for using the factory pattern?
>
> In Mail it's used like:
>
> $mail_object =& Mail::factory('sendmail', $params);
>
> while in Auth, _factory() is private and instantiated like:
>
> $a = new Auth("DB","mysql://martin:test@example.com/test");
I've made the factory method in PEAR::Auth private, bceause it's only
used to internally create a new instance of the storage container.
But in most other cases, a factory method is used to return a concrete
instance instead. In this case, the method needs to be public of course.
--
- Martin Martin Jansen
http://martinjansen.com/