#code doesn't work
foreach my $node (@{$nodes}){
my $ele = new Foo($node);
# use ele as a wrapper for $node
}
#end code that doesn't work
In this example Foo is used to extend or adapt the functionality and interface of $node, but doesn't confuse the framework by adding additional subclasses. If you are trying to add additional behavior to $node you want to use something called the Decorator pattern. If you are just trying to simplify the interface or change it to meet you expectation you want to use something called the Adaptor pattern. Both of these patterns use composition. Using Composition over inheritance will generally simplify your design.Scott Walters has put together a great Perl patterns resource called http://perldesignpatterns.com/?/ and has created a great explanation of what patterns (a highly recommended read) are. The decorator pattern is discussed here and the adaptor pattern is discussed here. Based on your question I think one of these may help.
Cheers,
John
In reply to Re: Is it a bad idea to subclass XML::LibXML ?
by raptnor2
in thread Is it a bad idea to subclass XML::LibXML ?
by nenbrian
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |