Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^8: Understanding Catalyst

by Your Mother (Archbishop)
on Oct 05, 2015 at 21:54 UTC ( [id://1143867]=note: print w/replies, xml ) Need Help??


in reply to Re^7: Understanding Catalyst
in thread Understanding Catalyst

It beats the crap out of 100 undecorated function calls and use|require statements sprinked all over the place and even embedded in the templates with contorted logic to surface instead of just being in [% c.model("WhatWhat").call %] and then something impossible to repurpose, let alone trivially change, with a simple back end swap. 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

Replies are listed 'Best First'.
Re^9: Understanding Catalyst
by Anonymous Monk on Oct 05, 2015 at 22:08 UTC

    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?

      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.

        ...relying enough on the M and the V. Let’s pick a more reasonable idea....

        Thank you. Do you have some links that are more in-depth ... that explain more of the why not just do-x like this?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1143867]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-24 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found