On 22/4/09 23:03, [email protected] wrote:
IMO the best place for your business logic is the controller.

Then you're wrong, at least in the eyes of many people.

http://en.wikipedia.org/wiki/Model-view-controller

The Controller is just a layer that converts the input to something that can be passed to the Model and then sends the output back to the user via a View.

You *can* put all your logic in the controller but typically you will end up with two problems:

1. Your app is tightly bound to a web framework and adding some other sort of user interaction, or extending the application code elsewhere becomes difficult, which is what started this thread isn't it ?

2. It becomes hard to test as you need to have the web framework running to run the tests. You should be able to test all of the use cases & business interactions outside of the web framework. If you can't, then that's a code smell and an indicator that you have too much going on in your Controller classes.

The Catalyst Model classes should really be a very thin shim over the top of your DBIx::Class Schema objects which is where all the 'heavy lifting' of the business process takes place.

Hope that makes sense,

Simon.

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to