|Problems? Is your data what you think it is?|
Catalyst and the stashby Mutant (Priest)
|on Jul 19, 2005 at 16:25 UTC||Need Help??|
Mutant has asked for the wisdom of the Perl Monks concerning the following question:
I've just started taking a decent in-depth look at Catalyst with a view to using it in the next major project coming up at work. I like a lot of it, but one thing that really bugs me is the stash.
It's basically a global variable, even though it's being passed round in the Catalyst::Context object. I don't have a problem with that, globals can be useful sometimes. But what concerns me is the way it's used to communicate between functions. eg.
Of course, you don't *have* to do it that way, especially since forward() now supports passing of arguments. But a lot of the Catalyst::* modules do things like (from Catalyst::View::HTML::Template for use with HTML::Template):
It seems most of the other view modules take this sort of a approach as well.
So you're just expected to put some things into the stash, forward to the view, and automagically your template gets populated with everything currently in the stash (whether you need or want it).
Again, you don't *have* to do it that way, you can easily create your own HTML::Template view module that passes parameters to the process() function, but it seems like the 'default' way of doing things is encouraging the use of stash.
What happens if another module decides to overwrite a whole lot of stash variables that you were using? True, there has to be sloppy coding along the line somewhere, but why make it easier for this sort of problem when you could just as easily protect against this sort of thing by passing parameters around?