> Am 11.02.2012 um 13:04 schrieb Jonathan Swartz:
> 
>>> 
>>> Nowadays, the action has moved on to other places, like the Catalyst list. 
>>> People still use Mason 1 and/or 2, but it's a much smaller part of their 
>>> development stack. This, BTW, describes me. I use Mason 1 solely for 
>>> templating on new projects. If I switch to Mason 2 that won't change.
>> 
>> Yes, sadly Dave is one of those that believe in a separate controller layer 
>> in modules. They are all wrong, but they comprise about 90% of the Perl 
>> community so what can you do :p
> 
> Could you explain your opinion about this "They are all wrong" a bit more ?

Nic Wolff summarized this pretty well, but I'll give my spin.

In Catalyst, URLs are handled by controller classes. A controller gathers data 
from appropriate model(s), then constructs a hash of data and passes it to a 
template to render the page.

In theory the controller method and template are decoupled, so that you could 
create multiple templates for a single controller method (one for browser, one 
for mobile, etc.).

In practice, there is almost always a one-to-one correspondence between 
controller method and template, and the two *are* quite coupled. If you want to 
figure out how a page is rendered, you have to look at both the controller and 
view. If you want to change how the page is rendered in any meaningful way, you 
have to modify both the controller and the view. So I find that with Catalyst 
development I'm constantly having to look in, and edit, two places at once. I 
also have more decisions to make about which code goes where.

In Mason, URLs are handled by components. A component gathers data from 
appropriate model(s), then renders the page itself. You only have to look in 
one place and modify things in one place.

Now with Mason 1 one could make a case that it's better to put logic in real OO 
classes whenever possible. With Mason 2, components *are* Moose classes; you 
get just as much OO power and goodness in a component as you do in a class. For 
example, a component can have a BUILD method that sets up attributes based on 
URL, params etc., and a number of render methods that refer to those 
attributes. This is a much richer controller-view interaction than passing a 
hash between two completely separate pieces of code.

Jon


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to