srdst13 has asked for the wisdom of the Perl Monks concerning the following question:

I have been playing with Catalyst a bit (and who hasn't). It is a wonderful framework for getting going quickly with web development. However, particularly on the Model side, and to a certain extent on the View side, I would like to build my own models and views. I was hoping someone could clarify the inheritance pattern. The code for two different CPAN model modules is given here. One uses NEXT for creating the object and the other uses a different method. Which is the "correct" idiom (if there is one) and why?
package Catalyst::Model::CDBI::Plain; use strict; our $VERSION = '0.03'; use base qw[Class::DBI Catalyst::Base]; sub new { my ( $class, $c ) = @_; return Catalyst::Base->new( $class, $c ); } 1;
versus this:
package Catalyst::Model::DBIC::Plain; use strict; use base qw/Catalyst::Model DBIx::Class::Schema/; use NEXT; sub new { my ( $self, $c ) = @_; $self = $self->NEXT::new($c); return $self; } 1;
One quick and dirty Model class that I would like to use is DBIx::Simple (I know, not a model, but it works for some simple designs). Can folks suggest code for a generic DBIx::Simple Model (I have one that works and simply returns a new DBIx::Simple instance)?

Thanks,
Sean

Replies are listed 'Best First'.
Re: Catalyst and component inheritance
by phaylon (Curate) on Nov 24, 2005 at 13:27 UTC
    I can't help on the DBIx::Simple topic, but the latter seems more stable, hence you do not hardcode the new() call on Catalyst::Base. If I understood correctly, Catalyst::Model is also the right base class for models now.

    So, I'd vote for the latter.

    Ordinary morality is for ordinary people. -- Aleister Crowley