[singapore-pm] Class::Sniff - making object inheritance trees
Gaurav Vaidya
gaurav at ggvaidya.com
Sun Feb 15 09:52:37 PST 2009
Hey there,
I saw something cool on the Perl-QA mailing list today, and thought
this list might be interested. If you have to document complex object
hierarchies [1], the new Class::Sniff module might be helpful.
On Feb 16, 2009, at 12:49 AM, Ovid wrote:
> 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
There's a Git repository on GitHub, too, so customizing this for your
own use should be pretty easy. Hope this helps!
cheers,
Gaurav
Footnote [1]: Not me -- the best thing about working in a startup is a
complete absence of legacy code! :-P
More information about the Singapore-pm
mailing list