in reply to Re: Re: Often Overlooked OO Programming Guidelines
in thread Often Overlooked OO Programming Guidelines
Now Bar is fully independent of Foo (coupled only by the implied "interface" which consists of the wonk() method). This also makes testing easier.package Bar; sub new { my ($class, %args) = @_; bless \%args, $class; } sub wonk { my $self = shift; $self->{_foo}->wonk(@_); # delegation! } package main; use Bar; use Foo; my $bar = Bar->new(_foo => Foo->new());
|
---|