(on Wednesday, 28 January 2009, 05:28 PM -0500):
> Would you shy away from pushing the model to the view because of layer
> separation, or do you think the mere separation of code (vs. usage)
> into different classes/scripts is fine ?
If you look at most of the classic MVC diagrams, they actually show the
view accessing the model -- so, to me, pushing the model into the view
so it can call methods on it seems perfectly reasonable. Another method
that myself and others recommend is creating view helpers that perform
the specific access necessary.
> -----Original Message-----
> From: Matthew Weier O'Phinney [mailto:matthew@zend.com]
> Sent: Tuesday, January 27, 2009 2:23 PM
> To: fw-mvc@lists.zend.com
> Subject: Re: [fw-mvc] Action view helper question
>
> -- Ed Lazor <edlazor@internetarchitects.biz> wrote
> (on Tuesday, 27 January 2009, 10:41 AM -0800):
> > Which is better?
> >
> > Option #1
> > Using the action method to collect data and pass (push?) it to the
> > view through variables
> >
> > Option #2
> > Using action view helpers within views to retrieve (pull?) data for display
> >
> >
> > I've always read that the controller is supposed to prepare everything
> > for the view. Option #2 seems like a cleaner approach though, so I'm
> > wondering what you think.
>
> Option #2 is a lot of overhead, and terrible from a performance
> standpoint.
>
> The point of the Controller in the first place is to manage the
> environment, and determine what models and views need to be
> instantiated. Typically you will push results of queries to your model
> into your view, or simply push your model into the view; the view then
> determines what to display, and how to display it. When seen from this
> view point, using the action() view helper seems like an indirection --
> it's treating actions as if they were models.
>
> So, short answer, use Option #1.
>
> --
> Matthew Weier O'Phinney
> Software Architect | matthew@zend.com
> Zend Framework | http://framework.zend.com/
>
--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论