[Catalyst] Reusable actions, AOP vs. other styles
Sebastian Riedel
sri at oook.de
Fri Apr 7 10:31:54 CEST 2006
07.04.2006 09:31 Dominique Quatravaux:
> Would you please offer some enlightenment as to why you prefer AOP?
Base classes affect the whole controller, reusable components just
the action.
package MyApp::Controller::Foo;
use base 'Catalyst::Controller';
sub add : Local : Action('Add') {}
sub del : Local : Action('Del') {}
IMO the above example is easier to understand and maintain than the
following.
(Especially when your Controller contains 20 or more actions,
which may all inherit something from a reusable action)
package MyApp::Controller::Foo;
use base qw/Catalyst::Controller GenericAdd GenericDel/;
use NEXT;
sub add : Local {
my ( $self, $c, @args ) = @_;
$self->NEXT::add( $c, @args );
}
sub del : Local {
my ( $self, $c, @args ) = @_;
$self->NEXT::del( $c, @args );
}
--
sebastian
More information about the Catalyst
mailing list