The day after the first Wednesday of every month - was Re: London.pm Meeting - April 5th

Luis Motta Campos luismottacampos at yahoo.co.uk
Wed Mar 28 07:36:40 BST 2007


On Mar 27, 2007, at 6:57 PM, Ash Berlin wrote:
> Andy Armstrong wrote:
>> On 27 Mar 2007, at 17:34, Andrew Black wrote:
>>> It would be clearer (IMHO) if it said something like "We meet on  
>>> Thursday with date between 2 and 8 of the month".
>> Inclusive? Exclusive? Inc/Exc? :)
>> --Andy Armstrong, hexten.net
>
> $meeting = $today if $today->day eq 'Thursday' and $today- 
> >dayOfMonth >= 2 and $today->dayOfMonth <= 8;
>
> Happy now?

   Damian Conway says on Perl Best Practices that this is bad coding.
   Refactor it:

   # Calculate $meeting based on Heretic Meetings rules (yes,  
"Heretics Rules"!)
   if( $today->day eq 'Thursday' and
       $today->dayOfMonth >= 2   and
       $today->dayOfMonth <= 8
     ) {
       $meeting = $today;
   }

   otherwise, provide a routine for decision making:

   =pod

   =item * C<B<is_heretic_meeting_day($today)>>

   Returns true if $today is the Heretics Social Meeting day.
   Otherwise, returns false.

   =cut

   sub is_heretic_meeting_day {
       my $today = shift;
       return $today
           if $today->day eq 'Thursday' and
              $today->dayOfMonth >= 2   and
              $today->dayOfMonth <= 8   ;
   }

   []'z!
--
Luis Motta Campos (a.k.a. Monsieur Champs) is a software engineer,
Perl fanatic evangelist, and amateur {cook, photographer}




More information about the london.pm mailing list