[Catalyst] how to reuse Catalyst Schema for non-web purposes?
Simon Wilcox
simonw at digitalcraftsmen.net
Wed Apr 22 22:21:20 GMT 2009
On 22/4/09 23:03, kakimoto at tpg.com.au 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.
More information about the Catalyst
mailing list