[Catalyst] Alternatives to Catalyst ?

Ben van Staveren benvanstaveren at gmail.com
Tue Apr 27 02:00:34 GMT 2010

> If using  ->params->{name} (i.e. the direct hash approach) is like
> juggling grenades - then what is like using the ->param( 'name' ) way
> of doing it?
Actually ->params->{name} is the juggling teddybears one (the "proper" 
way to do it). If you do $c->{request}->{params}->{name} - that's the 
grenade way.

-.param('name') is juggling sharp knives :)

> I am asking this because your grenades analogy gives the impression
> that you you are against doing direct hash access for every price -
> but I think the general advice is that in this particular case using
> the ->param( 'name' ) is worse than using the direct hash access.
Sorry if I wasn't quite clear on it, in the specific case of 
$c->req->params and consorts, doing $c->req->params->{ ... } is the 
"right" way to do it, after all, params returns a hashref and offers no 
further encapsulation; using ->req->param('foo') would work, but is just 
a compatibility shim for CGI and comes with some major drawbacks.

I was, however, speaking in general; it's often better to be able to do 
$object->get_foo/$object->set_foot (or $object->foo which does both), 
than to go $object->{foo} = ...;

In some cases, it's not, sometimes you need to get rid of the overhead, 
but the common "idea" at that point is that IF you need to break 
encapsulation, comment it right, and indicate WHY you're doing it.


Ben van Staveren
phone: +62 81 70777529
email: benvanstaveren at gmail.com

More information about the Catalyst mailing list