[Catalyst] Bing!

Perrin Harkins perrin at elem.com
Thu Aug 11 16:14:17 CEST 2005


On Wed, 2005-08-10 at 22:46 -0300, Luis Campos de Carvalho wrote:
>    Uh? It seems that I'm doing something kinda wrong, since I'm 
> registering my Model methods as Local and pointing url's to them...

We were actually talking about separating the view from the URL, but
most people would probably not do what you are describing.  Common
practice in Catalyst, Rails, etc. is to make the model a thin layer of
record-set objects using Class::DBI and put the application logic in the
controller.  The classic MVC approach agrees more with how you're doing
it, where the controller just maps button clicks to methods in the
model.

> Shall I always write Controller methods to handle my urls, never 
> relaying on the Catalyst Dispatcher for this job?

If you prefer to put all the application logic into the model, that's
fine.  Some systems, like Struts or OpenInteract2, make a distinction
between the application logic and the database objects, calling the
application logic "actions" or something similar.  In that scenario, the
action classes contain the logic for carrying out an action that goes
beyond a single database object's scope.  The action class is kept
separate from the web context (all parameters it needs from the web are
grabbed by the controller and passed in to the action class) so that it
can be used from scripts outside of the web.

In general, this separation is a core value of MVC: making your
application logic reusable from command-line scripts.  If your model
code is using web info from $c directly, that won't be possible for your
system.

- Perrin




More information about the Catalyst mailing list