Chained attributes are like crack. Once you grok them and start using them you can't stop. They simplify code so much.
I understand what chained attributes do. And Catalyst was a lot of fun to work with when it first came out. I would like to offer my viewpoint on solving the same problem. Personally, if you read what dhoss says chained attributes are for:
Chained, however, allows you to chain together methods that need to share information across requests....
Basically, in OO terms, what he is saying is that he has a sequence of methods that belong in the same class because they consume the same data. And if you look at the implementation:
sub base : Chained('/') PathPart('item') CaptureArgs(1) {
The use of the word 'base' is a dead giveaway.

So, what I see here is the use subroutine overloading to give Catalyst hints about how to handle common object-oriented programming problems for you.

I came up with a similar strawman example here.

The big difference is that I used clean, standard class-based OO to create a base class and then allowed the derived class to share/refine behavior as needed.

I personally dont like learning things like Catalyst and Template Toolkit. In my eyes, they are attempts to take what any OO Perl programmer can do himself and come up with syntactic trickery and shortcuts to make it easier for those who lack said sophistication.

Just give me Moose, CGI::Prototype and HTML::Seamstress and the tried and true methods of OO programming which work in and out of Perl anyday over language-specific syntax games like this.

But of course, we all have our preferences and I'm sure many people are getting great mileage out of Catalyst and Template, so more power to them!

Thanks for the chance to offer a contrasting viewpoint.


In reply to Re^2: Catalyst: Using Chained for URL Dispatching and Sane Method Organization by metaperl
in thread Catalyst: Using Chained for URL Dispatching and Sane Method Organization by stonecolddevin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.