2008年12月4日星期四

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

Hi everyone,

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

Currently, I have an Abstract controller with three factory methods.
AbstractController::getModel()
AbstractController::getDataGrid()
AbstractController::getForm()

My intention is to refactor the abstract controller methods into the
following action helper classes.
This way, functionality is called per use instead of assuming that they will
be used.
Of course, I could add the factories into the Registry, but that's just
polution.

I'm creating the following action helpers:

- 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.

Forgive me if I'm asking an obvious question, this is technically my first
attempt at using Zend Framework outside of spikes, tutorials and
documentation, so I'm a little unsure as to what the common usage is.

Thank you in advance.

rvdavid
--
View this message in context: http://www.nabble.com/Refactoring-Abstract-class-Factory-Methods-to-Action-helpers---is-this-overkill--tp20848552p20848552.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: