[Catalyst] The model -is- where your business logic lives.

Pedro Melo melo at simplicidade.org
Fri Sep 28 10:51:17 GMT 2007


Hi,

On Sep 28, 2007, at 8:22 AM, Dami Laurent (PJ) wrote:

>
>
>> -----Message d'origine-----
>> De : Matt S Trout [mailto:dbix-class at trout.me.uk]
>> Envoyé : jeudi, 27. septembre 2007 22:44
>
>> Don't confuse class -names- with the nature of classes.
>> MyApp::Model:: is
>> *adapters* that make a model available to MyApp, not where
>> your domain model
>> logic itself should live.
>>
>> I usually these days have MyApp::Web for the catalyst app
>> instead of MyApp so
>> I can deploy things like MyApp::DataStore from a separate dir tree.
>
>
> Makes a lot of sense to me. So the model can be used not only from  
> the catalyst App, but also from batch jobs, command-line utilities,  
> etc. And the Catalyst model *adapters*, as you call them, merely  
> load the appropriate external modules, that's all.
>
> But then comes a question about writing Catalyst code : which is  
> best between a) and b) below ?
>
> # a) go through the adapter for every method call
> $c->model('Some::Model::Adapter')->do_stuff()
>
> # b) directly call the external model after it's loaded
> My::External::Model->do_stuff()

b) here exactly for the same reasons: i like having the same API when  
I'm using Cat or not.

Besides, most of my projects have two sites (frontoffice, backoffice)  
so I prefer to have the connection details outside the catalyst sites.

I never did use $c->model in my sites...

> My colleague prefers a) because it's the usual, "oficial" Catalyst  
> way, and because if we ever need some reverse interaction from the  
> model to the controller, we can add stuff in the adapters, playing  
> with ACCEPT_CONTEXT.

Callbacks work for me when I need to do this.

Best regards,
-- 
Pedro Melo
Blog: http://www.simplicidade.org/notes/
XMPP ID: melo at simplicidade.org
Use XMPP!





More information about the Catalyst mailing list