[Catalyst] Catalyst MVC Best Pratices
Matt S Trout
dbix-class at trout.me.uk
Mon May 7 15:03:40 GMT 2007
On Thu, May 03, 2007 at 06:22:12PM +0100, Anthony Gardner wrote:
> Greetings,
>
> I've had a look at Catalyst and RoR from a basic point of view and like both. I'm also familiar with the concepts of MVC but again, from a basic point of view. I'm also busy learning design patterns etc.
Shame RoR isn't MVC - it stuffs all the business logic into the controller,
which is utterly utterly wrong.
> So, would this be better (haven't thought this through because as I said, my head is too full) ? .............
>
> lib/P4C/Controller/SelectProduct.pm
> /Model/Product.pm
> /P4CSchema/Product.pm (amongst others)
> /P4CSchema.pm
> /P4C.pm
> /Logic/Product.pm
>
> and have in Model::Product one of.....
>
> use base qw|Logic::Product Catalyst::Model::DBIC::Schema|;
> use base qw|Catalyst::Model::DBIC::Schema Logic::Product|;
>
> and let Logic::Product do the .......
>
> sub get_all_products_that_like_me() {
> }
>
> Is that's what meant by 'wrapper'?
Looks sane to me. What I usually do is have my MyApp::Model::* classes be
an interface to the domain model which holds onto a $schema or similar
internally and never exposes it - this is also known as the FacadeModel
pattern.
Catalyst::Model::DBIC::Schema is a thin model that simply reflects the domain
model into the app namespace, and should only really be used for simple
apps and/or apps where the domain model -is- the site (think a blog or a
flickr clone or ...)
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director Want a managed development or deployment platform?
Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
http://www.shadowcatsystems.co.uk/
More information about the Catalyst
mailing list