2008年9月22日星期一

Re: [fw-mvc] Application structure

-- Jiří Němec <konference@menea.cz> wrote
(on Monday, 22 September 2008, 09:45 PM +0200):
> I would like to ask about "where should I put the code". Sometime
> I am asking myself, should I put this code into model or leave in
> controller or create own library class..?

I'm thinking you're looking at an old version of the QuickStart. Please
take a look at the new version, launched last Monday, and download the
tarball associated with it -- and see if it answers your questions.


> For example, there is a new user account registration process. I have
> to show a registration form in a controller (should I create the form
> object in the controller or create new class extended from the
> Zend_Form or create the form object in the controller...?), after
> submitting there is need to validate data (should I do it directly in
> the controller or in a library...?), then I save a user account data
> (again, do it in the controller, model or a library which will
> cooperate with a model...?) into the database table...
>
> I'm thinking that controller should respond to all user requests (and
> should not contains any business logic) and through (library) objects
> works with models and access data sources and do anything else.
>
> I am asking you because when I looked over your quick start
> application, there is in GuestbookController two protected functions -
> _getModel() and _getGuestbookForm() and, maybe I am totaly wrong, but
> this doesn't fit in my concept of M/V/C separation (I would rather put
> this code into separeted class object which returns a concrete form
> object).
>
> I know there is no dogma about this question and probably this be up
> to each programmer, but are there any advices/propositions/rules how
> to divide a ZF (or whatever other MVC) application and where to put
> the code? I still haven't found sufficient answers for my questions.
>
> What do you think abou it? What is your best practise?
>
> Thanks in advance, J.
>

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: