I'm sure I'll add more later, but for now, I've just uploaded Class::Sniff to 
the CPAN and it's also on github 
(http://github.com/Ovid/class--sniff/tree/master).

If anyone wants to bang on it, that would be great.  I'd be interested to know 
if it works on 'real' code :)

  my $sniff = Class::Sniff->new({
      class  => 'My::Customer',
      ignore => qr/DBIx::Class/,  # optional
  });
  foreach my $method ($sniff->unreachable) {
      print "Cannot reach method ($method)\n";
  }

  # useful if you find yourself overriding methods you didn't expect to override
  my $overridden = $sniff->overridden;
  while (my ($method, $classes) = each %$overridden) {
      my $classes = join ', ' => @$classes;
      print "Method ($method) is defined in ($classes)\n";
  }

It assumes Perl's standard left-most/depth-first inheritance search order, but 
you can override that with the 'paths' method.  It does a lot more than what's 
listed above and is fully documented, including explanations of various OO 
'code smells'.


Note that if you are not using multiple inheritance, you won't have any 
'unreachable' methods.

Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

Reply via email to