It beats the crap out of 100 undecorated function calls and ... :P What does that mean?
Why would you need use/require embedded in templates?
c.uri_for() might seem gratuitous too if you’ve never grown an app that needed testing, flexible deployment, or midstream changes that could otherwise be trivial. :P
uri_for is one function, its not an entire new namespace whose only reason to exist is so some other name space can register a model with catalyst -- why does it need an extra class to inherit from an adaptor?
The answer may seem dead obvious as "beats the carp" but could you elaborate?
| [reply] |
Okay. I thought you were being a bit… contrary. But it's a real question and a real concern. To address it might take volumes though. …trying to boil down… …working… …loading…
Non-colliding namespaces are cheap, nearly free, in Perl. The main point of MVC is organizing concerns, organizing thought. Interpreter don’t care. Dev does. The controller should do nearly nothing. Really. Including hardcoding itself. uri_with, uri_for, and uri_for_action make the controllers themselves terribly flexible. Fat models (where the business logic is part of the data control) are the most reusable and therefore the obvious choice. Views should do all the branching of what is sane to show. The Controllers therefore do only the most obvious filtering, dispatching. A controller sub longer than… 40 lines is probably in need of abstraction or not relying enough on the M and the V.
Let’s pick a more reasonable idea than Games::Dice. Let’s try LWP::UserAgent. Now your Controller classes are *littered* with has "ua" =>, my $ua = …, and such. Completely uncool but obvious, understandable, readable. Then you decide you wanted to do a bit more and want to update to WWW::Mechanize. You have 20 Controllers and hundreds of lines of code to change, validate, test, and pray; maybe more if you were using default headers or something. Or you adjust the base class of your Model. The point of something as grand as Catalyst is growth. If you don’t care, or won’t grow, then bare Plack/PSGI is there or Mojolicious::Lite, etc. Gratuitous “best practices” are only gratuitous if the code is throw-away.
| [reply] [d/l] [select] |
| [reply] |