Examining Inheritance Hiearchies
Ovid
publiustemp-perlqa3 at yahoo.com
Sun Feb 15 16:49:43 GMT 2009
If you're struggling to understand a complex app, a graph of the inheritance hierarchy can be very useful. Here's an example for TAP::Parser:
http://i82.photobucket.com/albums/j275/publius_ovidius/Geek%20Stuff/graph-5.png
It's generated with this code:
#!/usr/bin/env perl
use strict;
use warnings;
use Class::Sniff 0.08;
use TAP::Parser;
my @sniffs = Class::Sniff->new_from_namespace({
namespace => 'TAP::Parser',
universal => 1,
});
my $graph = $sniffs[0]->combine_graphs( @sniffs[ 1 .. $#sniffs ] );
my $graphviz = $graph->as_graphviz();
open my $DOT, '|dot -Tpng -o graph.png'
or die("Cannot open pipe to dot: $!");
print $DOT $graphviz;
It should be on the CPAN soon. If you prefer, it's also on github:
http://github.com/Ovid/class--sniff/tree/master
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
More information about the tapx-dev
mailing list