>>>>> "SB" == Steve Bertrand <st...@ipv6canada.com> writes:

  SB> On 2010.05.07 19:02, Harry Putnam wrote:
  >> It looks pretty awkward, the way I just kind of wedged the default
  >> action in there... is there a more canonical way of doing that?

  SB> I have to be honest ;)

  SB> There was a time a little while back that I decided that I would try
  SB> hard not to troubleshoot code with variables named like this:

  >> my  @ar1 = ("r2one","r2two","r2three","r2four","r2five","r2five","r2four",
  >> "r2four","r2three","r2two","r2seven","r2six");

  SB> (fwiw, and I don't have time to get into the rest of the code right now,
  SB> I prefer whitespace, so I'd write that as):

  SB> my @ar1 = qw (
  SB>           r2one
  SB>           r2two
  SB>           r2three # comment, reader needs info for this var
  SB>           r2four
  SB>           r2five  # more comments
  SB>   );

it was a good idea suggesting qw but you can't put comments inside it
just like you can't inside any quoted string.

and i agree, the names are useless and generic. might as well name them
foo.

  SB> ..etc. However, there's probably another way to do that, but without
  SB> knowing what your variables *mean*, it's too hard to tell.

names should reflect usage, not be a placeholder or nmenonic.


  SB> my $v4glue  = $dns->v4glue();
  SB> my $v6glue  = $dns->v6glue();

  SB> $self->data({ field => 'v4glue', value => $self->date() }) if $v4glue;
  SB> $self->data({ field => 'v6glue', value => $self->date() }) if $v6glue;

  SB> I mean no offence. If anything, use more whitespace. Here's another
  SB> quick rewrite (let the Gods fix it better, as I didn't bother actually
  SB> reading what the code does ;)

  SB> my @exp;
  SB> my $r1name = 'r1_r1r1';
  SB> my $arcnt = 1;

  SB> for my $element ( @ar1 ) {

  SB>   push @exp,$element;

  SB>   $arcnt++;

  SB>   if (( $arcnt % 4 ) == 0 ) {

  SB>         dispt( $r1name, @exp );

  SB>   # my instincts say that $arcnt should be reassigned
  SB>   # within this for loop...

  SB>         @exp = ();

i haven't looked at the previous code but why is that being cleared here
and pushed above? i don't get the purpose of the mod counter either. it
just seems very odd but maybe there is a purpose. i won't delve to find
out.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to