[Catalyst] [OT] ASP.NET MVC
Matt S Trout
dbix-class at trout.me.uk
Sun Dec 16 20:06:44 GMT 2007
On Tue, Dec 11, 2007 at 07:59:48AM -0800, John Napiorkowski wrote:
> And with chaining you could create all the chained
> actions in a single class, or use the Chain(.) feature
> to spread this over a couple of controllers. That's
> what I usually do, but then you sometimes end up with
> a mess of nearly empty controller classes.
I find they're usually only nearly empty at the beginning of development - by
the time the app's gone through a couple of iterations they aren't anymore
and you're glad you split things out.
> Then we also have :Local, which is also considered
> somewhat deprecated in favor of :Path
Wrong.
Although to be honest I don't really use anything except :Chained these days :)
> :Default which
> is recommended only for things like capturing bad URLs
> and directing to a not found page (or if you are
> clever, so sort of soundex or spelling correction to
> see if that would match a known url)
'default' and 'index' -are- deprecated.
You want
sub works_like_default :Path {
and
sub works_like_index :Path :Args(0) {
> Another potential disadvantage of this, besides the
> confusion, is that you end up which a Controller
> namespace generally having to map to your URI
> namespace, and if you need to change the URI namespace
> you end up renaming and moving controllers, around.
No. Really. Don't ever do this.
Chained doesn't pay attention to the controller name.
__PACKAGE__->config(prefix => 'foo')
changes the path prefix of the controller (for Path, Local,
LocalRegex) without affecting the controller name, action
namespace etc.
> What do the rest of you think? What could be better
> or more clear in terms of best practices? Because I
> think this is a place where a lot of newbies get lost,
> and compared to the 'there's only a single way to do
> it' method of using router classes, we can lose out.
We could probably do with a 'guide to using Chained', and
I've been pondering a cleaner syntax for it but don't really
have anything I'm happy with yet.
Note also that as I keep telling people, setting action attributes
via config makes it trivial to do a central routing table; just
nobody seems to like the feature enough to write a guide to how to
do it :)
> Also if we could work up an example that showed the
> benefit of the Catalyst way that would also help us.
The base class related examples I've posted a couple times demonstrate this.
If I work up an advent entry on them would you be willing to expand them for
the main manual?
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
More information about the Catalyst
mailing list