Hello, Simon, Your points have good weight for thoughts. In fact, coming from many backgrounds pre-Catalyst and pre-MVC (ie many a times, the templating system ie Mason would do the job of both controller and view incorporating the business logic), I have been able to write regression tests to test methods within an ORM.
When I first started using Catalyst, I looked at the tutes and so forth and it seemed to me that the only form of testing is just web based (ie using web robots like Test::WWW::Mechanize::Catalyst). Whilst that allowed a good test of the interface and functionality as a whole(akin a blackbox), I missed the days when I had to develop something without the web front end and have it work for both web and back end(ie via scripts). Your arguments here have raised a direction for me to put my business logic into the model component of my app. Nevertheless, can I ask for some references to examples of business logic being written in the model? I can't seem to observe any from the Catalyst tutes. thank you K. akimoto Quoting Simon Wilcox <[email protected]>: > 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/
