[Catalyst] best practice: where to put constants

Lance A. Brown lance at bearcircle.net
Thu Jun 4 16:14:58 GMT 2009


Alejandro Imass wrote:
> Although I think there is no best practice as such, I mean there are
> many ways to do this in Perl in general, but Catalyst offers the nice
> feature of the main config file in YAML, so I keep all my constants
> and configuration values there.
> 
> YAML is so powerful that IMHO it's the best place not ony to store
> your constants but to structure them intelligently. Of course, all the
> constants you put in your YAML file will be vailable through
> $c->config->{foo}

I wouldn't put these constants in the applications main configuration
file unless the constants are for the application. Jarom's example
indicates the constants have to do with data coming from a model so I'd
put them in a package in the model's namespace.  That way MVC separation
is maintained *and* you have access to the constants outside the
catalyst app if needed.

--[Lance]


-- 
 GPG Fingerprint: 409B A409 A38D 92BF 15D9 6EEE 9A82 F2AC 69AC 07B9
 CACert.org Assurer



More information about the Catalyst mailing list