[Catalyst] Catalyst::Model::DBIC::Schema or not?
Alejandro Imass
alejandro.imass at gmail.com
Fri Mar 23 21:13:11 GMT 2007
Just my $.02
IMHO, the M is correctly defined as is in Catalyst, and you should
definitively keep the Model. Depending on which "business logic" you
are refering to, the code should go in any of Controller, Model (aka
the ORM layer) or the Database.
Furthermore, I think that ORM is just that: clean, powerful,
maintainable access to your database, in fact, anything that pushes
the ORM a bit too far should go IN the database. In practice, you will
find that many of the procedures stored in the model classes will
probably wind up in the databse for performance issues, so what I have
done is set the boundary right there from the beggining (the point
where you feel that you are pushing the ORM a bit too far). Any
complex business logic should always be in the DB (if you are using a
decent database such as PostgreSql, Oracle). The power, encapsulation
and performance gains of using views and rules on a RDBMS like
PostgreSql is without question. Unless you _really_, _really_ have
serious portability issues, and not willing to maintain several sets
of DB code, always consider programming the complex stuff in the DB.
Cheers,
Alejandro
On 3/23/07, Brian Kirkbride <brian.kirkbride at deeperbydesign.com> wrote:
> Jason Gottshall wrote:
> > Catalysters:
> >
> > I'm developing a new app using Catalyst, with DBIC as the db persistence
> > layer. I intend to build Models that encapsulate the business logic and
> > that will use DBIC to interact with the database as necessary, instead
> > of using DBIC as a "model" itself.
> >
> > So if I'm not using DBIC from the controller directly, is there any
> > reason for me to use Catalyst::Model::DBIC::Schema? It seems like I'm
> > just adding an unnecessary layer of code.
> >
> > Comments from any of you who have a similar setup would be especially
> > welcome.
> >
> > Jason
> >
>
>
> I only have Model classes for my business logic and have never had a problem
> with that. A bonus is that it forces you to say:
>
> $c->model('MyLogic')->_get_schema->resultset('Users')
>
> instead of:
>
> $c->model('Schema::Users')
>
> and that makes you think about ugly hacks that circumvent your business logic.
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>
More information about the Catalyst
mailing list