For me it depends on two things:

1) What it *absolutely* required for the Class to be usable? Everything
that must be there should be in the constructor, other things via set
methods.

2) How long is the constructor? I'm generally not a fan of having a
constructor with 10's of parameters. This usually comes about by not
following point #1

But it comes down to personal preference :)

Alex.

On Thu, Aug 16, 2012 at 7:43 PM, Ralf Eggert <r.egg...@travello.de> wrote:

> Hi again,
>
> another question came to my mind. Which way do you prefer.
>
> Using the constructor to pass objects:
>
>   'User\Mapper\User' =>  function($sm) {
>     $table  = $sm->get('User\Table\User');
>     $mapper = new UserMapper($table);
>     return $mapper;
>   },
>
> Or using setter methods to pass objects
>
>   'User\Mapper\User' =>  function($sm) {
>     $table  = $sm->get('User\Table\User');
>     $mapper = new UserMapper();
>     $mapper->setDbTable($table);
>     return $mapper;
>   },
>
> Any comments?
>
> Regards,
>
> Ralf
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>

Reply via email to