the registry is global too and it has no type checking, which makes a
global
class that has setter and getter for specific types winner over a
general registry in my opinion.

static classes that contain objects and are used inside dynamic objects are
always
an obstacle to testing, singletons more than registries but the problem
does not
disappear. a registry is nothing different than a "global
$arrayWithObjects;" inside a function,
just object oriented.

The recommended approach (that is independend of Zend or whatnot) should
always be explicit
dependency injection.

greetings,
Benjamin

On Fri, 9 Jan 2009 23:31:38 -0500, Matthew Weier O'Phinney
<matt...@zend.com> wrote:
> -- swilhelm <st...@studio831.com
> wrote
> (on Friday, 09 January 2009, 12:26 PM -0800):
>>
>> I have been Reading Cal Evan's Guide to Zend Framework Programming.
>>
>> In it he describes a Globals.php file for creating a single class to
>> encapsulate access to global resources like the database connection,
> cache
>> connection, config, etc.
>>
>> This seems useful, particularly if you use it in conjunction with his
>> Controller_Request_Cli class for exposing some of your Zend-based
>> application via command line or cron jobs.
>>
>> I was wondering if this is the recommended approach to exposing global
>> resources or is there a Zend Framework "approved" method?
> 
> I've had some back and forth with Cal on his Globals class. :)
> 
> I personally feel that this is primarily the realm of a registry or
> dependency injection; a class of static methods is typically difficult
> to test against, and makes it more difficult to determine what the
> actual dependencies are for classes that pull from it.
> 
> Zend_Application may very well make such a Globals class obsolete, as it
> will make it easier to handle your dependencies and push them either
> into the registry or directly into the objects that need them.
> 
> --
> Matthew Weier O'Phinney
> Software Architect       | matt...@zend.com
> Zend Framework           | http://framework.zend.com/

Reply via email to