On 5/22/07, Bill Moseley <[EMAIL PROTECTED]> wrote:
So, what have you found that works nicely?use MyApp::Const qw/ cart_pending /; # potentially long list cart_status => cart_pending # runtime checking use MyApp::Const qw/ :cart /; # Shorter list :) cart_status => MyApp::CONST::pending, # global constants # Make it very clear where a constant should be used # by adding the constants as methods to the cart namespace cart_status => $cart_class->pending_status
I think I've done all of these over the years. Adding them as methods is probably my favorite, but importing constants is okay (although I use $CART_PENDING_STATUS so it will interpolate in strings). Put the constants in the cart class -- MyApp::Const becomes a mess very quickly. What bothers me about these is that I have the constants in two places, but elaborate schemes to read them on startup always seemed like they create more problems than they solve. If I had one where the contents changed a lot at runtime, I would just make a real ORM class for the lookup table and hope that my database caches queries well. - Perrin _______________________________________________ List: [email protected] Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
