Anyway, you only need to instantiate the object once in each controller's
init() method.

public function init()
{
    $this->_registry = Zend_Registry::getInstance();
    // Or $this->_registry = $this->getInvokeArg('registry');
}

Here you make assumption that I use MVC and implement init() methods for controllers. But many of the uesers would do neither, and using MVC should not be related to using registry. Registry should be easy to use with or without MVC. Using getInstance() requires you to know that Registry is a singleton which is working in certain way. It is the knowledge that in most cases you do not need.

No one's suggesting using a global variable, only that it is possible to

Well, I distinctly remember an email where somebody *was* suggesting using global variable ;)

use Zend_Registry in many different ways.  I prefer to pass it as an
invocation argument to the front controller, which makes it available to
all actions.  Most others probably prefer the Singleton interface.

Again, you assume everybody uses MVC with front controller and everybody knows what Singleton is and prefers to use it. I don't see how any of these things should be prerequisite for using the registry.

You mentioned that new users will find the Singleton pattern confusing.

No, I don't think they should get even to finding Singleton pattern *anything*. They don't need to know about it's existence. They shouldn't be bothered by it.

If someone isn't familiar with basic design patterns, they'll probably
find the internals of most of the components in the framework confusing or
mysterious.  For example, the front controller (it uses a Singleton as

The we already lost the game and should return to the design stage, because deep knowledge of design patterns as the prerequisite for using any framework is totally unacceptable if we talking about PHP target audience. It can help you do advanced stuff, but it should not be required. Basic usage should be - *extremely simple*.

Fortunately, I disagree with that assumption - most interfaces in framework do not require knowledge of design patterns, unless these very interfaces are done with purpose of implementing those patterns (like MVC) and unless you want to do advanced stuff that requires in-depth understanding of how Framework components are implemented. You don't need any patterns to use Zend_Feed or Zend_Db - you just instantiate the class and use it. We should keep it that way.

well).  But just because users might not understand the internals doesn't
mean they can't use it.  That's what the manual is for.

In the case of over-designed interfaces - they have to. Framework should be so easy to use that you don't really need to read the manual for at least basic usage - just to look at a couple of the examples and be intuitively ready to use it without even diving into the details. Of course, it is not always possible - if you talk about complex stuff. But trivial stuff should stay trivial.

--
Stanislav Malyshev, Zend Products Engineer
[EMAIL PROTECTED]  http://www.zend.com/

Reply via email to