The ZF team wants to push for a conclusion with factories:

http://framework.zend.com/wiki/display/ZFDEV/Factories

Personally, I completely agree with you Chris, and even suggested removing Zend_Db. For me, whatever effort is required to map input choice selections onto selected plugin strings (first parameter of the factory method) is not better than the effort to require_once the adapter and then instantiate it.

Cheers,
Gavin

Christopher Thompson wrote:
I continue to wonder at the usage of statics. The use case where a factory might be needed was give as "configure the data source via GUI." But what is the real difference between:

   $dbconfig = "Zend_Db_Adapter_Pdo_Mysql"
   $db = new $dbconfig(...)

and

   $dbconfig = Zend_Db::PDO_MYSQL;
   $db = new Zend_Db($dbconfig, ...)

From my point of view, all the factory provides is more code to support and more overhead to create an object. I never liked this about PEAR::DB either.


Matthew Ratzloff wrote:
By class constants being a bit ugly, you mean like this?

$db = new Zend_Db(Zend_Db::PDO_MYSQL, ...)

Would this allow people to use their own adapters without having to extend
Zend_Db purely to add another constant?  The only way I can see that it
wouldn't is if it simply contained the string "Zend_Db_Adapter_Pdo_Mysql".

It might not be particularly important for Zend_Db since most people will be fine with the bundled adapters, but since we're going for a consistant
approach across all classes we need to consider how something like this
would work in all cases.

-Matt



Reply via email to