Subject: | XML::FeedPP cannot be subclassed |
Because of the way the new() method is implemented XML::FeedPP cannot be
subclassed. Although new() correctly uses the two argument version of
bless, it later reblesses $self. This which means that contrary to all
reasonable expectation the result of XML::FeedPP->new() will not be an
object of type XML::FeedPP. Similarly if you subclass XML::FeedPP and
call XML::FeedPP->new from your sub class constructor the result will
not be your subclass type.
Example:
package MySubclass
use base 'XML::FeedPP'
sub new
{
my $class = shift;
my $self = $class->SUPER::new(@_);
##..
return $self;
}
EXPECTED BEHAVIOR: $self is of type MySubclass
ACTUAL BEHAVIOR: $self is of one of the XML::FeedPP:: types
---
If this behavior cannot be fixed, at the very least the new() method
should be renamed to something that more accurately describes its
behavior e.g. 'parser_factory'.