MI == multiple inheritance
What he is basically saying is instead of having something like:
sub new { my ($class, %args) = @_; my $self = bless( {}, $class ); foreach my $k ( keys(%args) ) { $self{$k} = $args{$k}; } return( $self ); }
do something like:
sub new { my ($class, %args) = @_; my $self = bless( {}, $class ); $self->init(%args); return( $self ); } sub init { my ($self, %args) = @_; foreach my $k ( keys(%args) ) { $$self{$k} = $args{$k}; } # anyother initialization here }
This makes a clean separation between the construction and the initialization with no real downside.
Frank Wiles <frank@wiles.org>
http://www.wiles.org
In reply to Re^3: Object Constructors - Advice of experienced OO Perl Monks
by ides
in thread Object Constructors - Advice of experienced OO Perl Monks
by ghenry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |