A lot of times when I'm faced with this issue, my model method already
has a return value, but I suppose the error/success code could just be
passed under a separate key in the return array. I was just curious if
others had found ways to deal with this issue without the use of
return codes, or if some felt that, under certain circumstances, a fat
controller is justifiable. But in the end, using detailed return codes
is probably the most practical solution without breaking MVC.

On May 17, 8:36 pm, Jeremy Burns <jeremybu...@me.com> wrote:
> A good question, and I guess there are many different ways of handling this. 
> When I do it, I parse the data looking for obvious errors, trap processing 
> errors, react to validation errors etc. within the model then return an error 
> or success code to the controller. The controller then knows what to do.
>
> Jeremy Burns
> jeremybu...@me.com
>
> On 18 May 2010, at 00:27, calvin wrote:
>
>
>
> > So since I've started trying to implement the fat model, skinny
> > controller MVC pattern, I've continuously run into one issue--the
> > problem of dealing with user errors.
>
> > Fat model, skinny controller is great as it predisposes developers
> > towards a top-down development style that produces self-documenting
> > and more maintainable code. But I've found that, the more I try to
> > move the business logic to the model, the harder it is for me to
> > display detailed error messages or otherwise alter the view in
> > response to different use cases.
>
> > For example, if one is trying to write an action that allows the user
> > to upload a sales report, you could write something like:
> > function upload() {
> >    if (!empty($this->data) {
> >         if ($this->Report->upload($this->data) {
> >             $this->Session->flash('Sales report uploaded and
> > processed.');
> >             $this->redirect(...);
> >         } else {
> >             $this->Session->flash('Sales report could not be
> > processed.');
> >         }
> >    }
> > }
>
> > And in Report::upload() you might save the uploaded file and process
> > the sales data it contains.
>
> > But what if the file was successfully uploaded, but could not be
> > processed for some reason? E.g. how do you tell the user that the file
> > uploaded correctly, but its contents are incorrect? Or how do you tell
> > the user that the file uploaded correctly, but one of the products
> > referenced by the sales report is not in the database and must be
> > added first?
>
> > Has anyone else encountered this problem? How have others overcome it?
> > Do you throw lots of exceptions or just return an array that includes
> > error/status info?
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups 
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to