On 30 Oct 2012, at 14:03, Craig Chant wrote:

> So it seems it’s OK to whack them in the main MyApp.pm , here is an example 
> of what is currently in a ‘MemberGlobs.pm’, which is ‘required’ in 90% of all 
> the perl scripts.

<snip>

> I’m forever having to switch between UK dates and USA dates so have helper 
> methods.
>  
> Where do these go?

The example function was immutable, and side effect free.

As such, it's purely functional, and thus I'd import it (i.e. write a module 
which just exported functions, and export it from there).

> Also where do you put application global constants?

How constant is constants?

If it's configurable, it comes from the config file!

If it's a real constant (as per the functions above), same situation applies.

However, I'd suggest that if you need functions such as this, your entire 
approach is broken! You should be inflating all dates and times into DateTime 
objects, and then using a correctly configured DateTime::Formatter::XXX to 
format them as appropriate for the output context.

This would mean that you'd set the date format generically for a user / page / 
whatever granularity you want, and you'd do conversion in one or two places - 
thus supporting the DRY principle, and allowing you to be much more flexible in 
future, when you need other date/time output formats.

Cheers
t0m


_______________________________________________
List: Catalyst@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/

Reply via email to