Hi Matthew,

> Then you need to break your controller into multiple controllers, as
> it's managing too much.
> 
> The rule of thumb I have is: more than 5-7 actions in a controller:
> refactor. More than 1-2 forms: refactor. Otherwise, the workflow of the
> controller becomes too difficult to follow easily.

Interesting stuff. I am thinking about this, but the rules of thumb
might not fit on every case I think.

Here is an example controller I use for managing users by an admin:

---------------------------------------------------------------------
class AdminController
{
    public function indexAction()
    {
        // uses select form
    }

    public function addAction()
    {
        // uses create form
    }

    public function updateAction()
    {
        // uses update form
    }

    public function deleteAction()
    {
        // uses delete form
    }
}
---------------------------------------------------------------------

These are 4 actions and 4 forms. Would you really split this up in more
than one controller?

Here is another controller I have

---------------------------------------------------------------------
class UserController
{
    public function indexAction()
    {
    }

    public function registerAction()
    {
        // uses create form
    }

    public function updateAction()
    {
        // uses update form
    }

    public function showAction()
    {
    }

    public function activateAction()
    {
    }

    public function loginAction()
    {
        // uses login form
    }

    public function logoutAction()
    {
    }

    public function passwordAction()
    {
        // uses password form
    }

    public function forbiddenAction()
    {
    }
}
---------------------------------------------------------------------

This controller has 9 actions which use 4 forms. Well, I could move
loginAction(), logoutAction() and forbiddenAction() to an AuthController
and maybe registerAction() and activateAction() to a
RegistrationController.

But does that really make sense?

Regards,

Ralf

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to