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 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 [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to