2008年12月5日星期五

Re: [fw-mvc] Re[fw-mvc] factoring Abstract class Factory Methods to Action helpers - is this overkill?

Hey rvdavid,

>
> Following the old "favour aggregation over inheritance", I've decided to
> refactor my controller into using action helpers.

Yes, ever since the introduction of the action helper system (brokers and
all), this is the preferred way to go- using composition and aggregation
over inheritance.

> - Model factory
> // to use in in controller action method
> $this->_helpers->getModel('Users');
>
> - DataGrid Factory
> // to use in in controller action method
> ($this->_helpers->getDataGrid('Users');
>
> - Form Factory
> // to use in in controller action method
> $this->_helpers->getForm('Users');
>
> This to me seems like a semantic way of doing things, but I have a little
> voice in my head that says it may be overkill.
>

There is no "formal" way of doing this currrently, but to me, you are on the
right track. The overall idea is to create a system which "resources" the
controllers consume can be loaded and used.

That said, there is a proposal you should have a look at:

http://framework.zend.com/wiki/display/ZFPROP/Zend_Controller_Action_Helper_
ResourceLoader+-+Graham+Anderson

This might be something worth looking into and commenting on as its pretty
similar to your solution- only slightly more generic (its a single resource
broker instead of a broker per type of resource you are loading).

Hope that helps,
Ralph

--
Ralph Schindler
Software Engineer | ralph.schindler@zend.com
Zend Framework | http://framework.zend.com/

没有评论: