in reply to Re: Re: Often Overlooked OO Programming Guidelines
in thread Often Overlooked OO Programming Guidelines
Foo::_fiddle has no relation to the Bar::_fiddle method and the similarity of names is a coincidence. Unfortunately, calling the Foo::wonk method via an instance of Bar will still call the Bar::_fiddle method, even though this may not be desireable behavior. Not having clean encapsulation of private methods makes this very difficult to get around. You could try to get around it like this:I'd prefer to write that $self->Foo::_fiddle, even though it would be slower.# in package Foo sub wonk { my $self = shift; _fiddle($self, @_); }
That looks better, but if the private method violates encapsulation and reaches into the object (a common practice), it might be making assumptions about what's there, even if those assumptions are not warranted.Don't understand what problem/assumptions you see as problematic here. Can you elaborate?
I don't think I would use delegation for private methods; it feels like using a wrench to unscrew a lightbulb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Often Overlooked OO Programming Guidelines
by Ovid (Cardinal) on Dec 30, 2003 at 07:06 UTC |