MVCR pattern (was Re: [Catalyst] Bing!)

Perrin Harkins perrin at elem.com
Thu Aug 11 16:21:58 CEST 2005


On Thu, 2005-08-11 at 00:13 -0400, David Storrs wrote:
> As to MVCR...you know, that's a really good point.  All this  
> confusion about where the business logic goes should be a big red  
> flag saying that it does not properly fit in /any/ of the three  
> locations.

It fits just fine.  The original definition of "Model" is basically the
business logic.

> What are people putting in actions of their View classes?  Just a $c- 
>  >stash->{template} = 'xyz.tt'; line?

I would not expect to see anything more if you use TT.  If you use a
system like HTML::Template, you would need additional code there when
you want to do things like format dates or split data into two columns
for display.  Those things are not part of the model because they are
purely about the display of the data.

> What about the Controller?  Personally, I have chosen to put my  
> business logic in the Controllers, so their actions tend to be big.

That's fine.  Other systems have different names for it, but the code
amounts to the same thing.  The next step from this is to pull the
business logic into action classes that are separate from the web-
related code so you can use them from outside of a web environment.

> The Model?  Again with the personal--my Models are thin wrappers over  
> the DB.  They have no actions aside from the ones defined by  
> C::M::CDBI(::Sweet)?.

That is the common approach for web MVC systems like Catalyst.  Other
systems might not call that the model, but it would be a part of the
model.  It would be called Data Access Objects or just record sets.  The
names are not that important.

- Perrin




More information about the Catalyst mailing list