[EMAIL PROTECTED] wrote:
> Matt S Trout <[EMAIL PROTECTED]> on  08/18/2006 12:33 PM:
>  > Eeeeek, not at all. The model should encapsulate *all* business logic 
> and
>  > similar - it should be a model of the domain with which the app 
> interacts. The
>  > Controller should be as thin a layer as possible whose sole purpose 
> is to
>  > arbitrate between the model's view of reality and the user interface 
> (i.e. the
>  > view)
> 
> I disagree.
> 
> In an MVC sense:
> The model is the data.
> The controller is the business logic.  
> The controller receives commands from the user interface, and 
> manipulates the models.
> The models are then displayed via views

This is what I had thought initially, but I have come to see the benefit of 
doing it the way Matt describes.

I have Catalyst and non-Catalyst web applications, CRON jobs and command-line 
utility scripts for my project.  They all need access to the data in the model, 
and that is provided by the ORM.  That can be accomplished in either your way 
or 
the logic-in-the-model way.

But many of the command-line tools need to do the same thing as a controller in 
the Catalyst application.  Sometimes the CRON jobs do too.  Since the code in 
the Catalyst controller is dependent on the Catalyst request life cycle, it's 
not in itself reusable.  I don't want Catalyst controllers calling the external 
scripts either.

At this point, if I want code reuse I have two reasonable choices:

A) Create business logic modules, ie. MyApp::Logic::CreateTrial, etc
B) Write my own business logic methods in MyApp::Schema::Trial->create(...)

Either is valid and from what I gather Java developers like the Logic route.  I 
chose (B) because I already have the classes and the logic is *usually* just 
operating on that class's data model.

I'm very interested in hearing others' thoughts on this, because it really 
seems 
to be a point of contention in MVC/Web programming.

Best,
Brian

_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to