[Dbix-class] minimalistic Moose / DBIC glue module
John Napiorkowski
jjn1056 at yahoo.com
Sat Jun 26 18:58:03 GMT 2010
----- Original Message ----
> From: Eden Cardim <edencardim at gmail.com>
> To: DBIx::Class user and developer list <dbix-class at lists.scsys.co.uk>
> Sent: Wed, June 23, 2010 12:53:02 PM
> Subject: Re: [Dbix-class] minimalistic Moose / DBIC glue module
>
> >>>>> "Drew" == Drew Taylor <
> ymailto="mailto:drew at drewtaylor.com"
> href="mailto:drew at drewtaylor.com">drew at drewtaylor.com>
> writes:
Drew> I had thought in the past about where to
> separate the business
Drew> logic. Do I do it in
> MyApp::Hotel or
Drew> MyApp::Schema::Result::Hotel?
> Obviously canned queries go in
Drew>
> MyApp::Schema::ResultSet::Hotel, but where's the dividing line
> Drew> between an operation on a Result object? What policies are
> Drew> other people using to determine this?
Generally, I try to
> isolate the complexity of DBIC from the business
logic, because if you ever
> need to add a wrapper layer around DBIC, it's
going to be very hard to mimic
> the DBIC API efficiently. if you have
hairy calls to search(), for instance,
> those belong inside a DBIC
result/resultset, then your wrapper can
> encapsulate that in a call
that's simpler for your business logic API to
> handle, something like
$cds->with_genre('pop'), as opposed to
> $cds->search({ 'artists.genre' =>
'pop' }, { join => 'artists'
> }). As a rule of thumb, when you're
writing code in a controller or a
> business model, every time you have to
know/check the DBIC API docs or your
> schema ddl, that code should be in
a method inside a resultset/result
> class. You'll find that if you stick
to this simple principle, you'll
> be able to use your row objects
directly, without having to use wrappers
> until much later, and when you
do, the transition will be smooth and
> easy.
I generally try to do this as well, however I find that doing this for simple finds on primary keys gets a bit tedious, and frankly I wonder if I'm not wasting time and adding to complexity. Would be interested in your thoughts.
John
_______________________________________________
List:
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC:
> irc.perl.org#dbix-class
SVN:
> http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
More information about the DBIx-Class
mailing list