[Catalyst] ways to do stuff and why
Matt S Trout
dbix-class at trout.me.uk
Sat Aug 19 16:51:59 CEST 2006
Brian Kirkbride wrote:
> 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.
Actually, I tend to have a DBIC::Schema model called something like
'DataStore' and then write logic modules under Model::* that the controllers
call - so "mostly (a), with a bit of (b)"
I think the main bone of contention here is that Len is referring to his
persistence layer as the model, whereas I consider it to just be a persistence
layer - stuff like Model::DBIC::Schema is really only there for simple apps
where what you're modeling *is* the database. If you're modeling a domain,
then your Model::* stuff should be the model of the domain, and whether or not
said model happens to use DBIC stuff as its persistence store should be merely
an implementation detail that the Controller never sees.
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Catalyst
mailing list