* On Fri, Jun 20 2008, Aristotle Pagaltzis wrote: > * Jonathan Rockway <[EMAIL PROTECTED]> [2008-06-20 22:20]:
>> Yeah, that's ugly. What you really want are method modifiers: >> >> package MyApp::Controller::Foo; >> use Moose; >> BEGIN { extends 'Catalyst::Controller' }; >> >> sub main_page :Path Args(0) { >> my ($self, $c) = @_; >> $self->hello($c); >> } >> >> sub hello { >> my ($self, $c) = @_; >> $c->res->body('hello! setup is'. $c->stash->{setup}); >> } >> >> before hello => sub { >> my ($self, $c) = @_; >> $c->stash->{setup} = 'done'; >> }; >> >> 1; > > That’s even uglier. Imagine there isn’t just `hello` but half a > dozen other methods all sharing the same setup. So the setup code > is one or two screens down the source file. Now when you look at > `hello` you have absolutely no indication whatsoever that there > might be other code running before it. I guess. But this is Perl, there's never any indication of anything. There's no indication that my function is receiving arguments of a particular type. There's no indication that my function throws exceptions. There's no indication that "use Foo" has side effects. Even in Catalyst, there is a ton of implicit behavior. There is no indication that begin/end/auto applies to my action (at least until the action runs). So in other words, I disagree with you. I use method modifiers all the time, and I (and others) have no problem maintaining code. If you want ultimate verbosity, just call hello_setup from hello. If you think you can keep a few method modifiers straight in your head, then use the Moose approach. TMTOWTDI. > Note that using method modifiers instead of Cat dispatch means > that the Catalyst::Stats breakdown of a request will be coarser. The less my web framework does for me, the better. If I want profiling, I'll use DashProfiler. Regards, Jonathan Rockway -- print just => another => perl => hacker => if $,=$" _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/