[Catalyst] best practice: where to put constants

Alejandro Imass alejandro.imass at gmail.com
Thu Jun 4 17:02:58 GMT 2009


Yes of course, makes sense. Besides constants should "use constant"
also. Nevertheless, it is quite common to confuse/abuse constants with
'configuration constants' which should go perfectly in your main yaml
config file. My bad for not clarifying this.

On Fri, Jun 5, 2009 at 11:44 AM, Lance A. Brown <lance at bearcircle.net> wrote:
> 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
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>



More information about the Catalyst mailing list