Class::Method::Cannot?
Ian Malpass
ian at indecorous.com
Mon Apr 28 22:13:29 BST 2008
Peter Corlett wrote:
> On Mon, Apr 28, 2008 at 11:41:01AM -0500, Ian Malpass wrote:
> [...]
>> I want to inherit from a base class, but I want to not inherit methods
>> foo() and bar(). I could over-ride these with methods that die(), but
>> can() would still see them.
>
> In that case, you do not want to inherit from a base class. You want to
> encapsulate it in another class that only exposes the API that you wish to
> expose.
Actually, in the particular case of the problem I'm working on now, I
think I'm going to add in another base class to inherit from, and the
subclass that doesn't want those methods won't use that base class.
But that approach won't work all the time - is there anything out on
CPAN that helps with the encapsulate-and-expose approach? Or any design
recommendations?
Doing things properly is obviously a Good Thing, but it seemed a heck of
a lot simpler to say "this, minus these" than to go off and add do fun
stuff with extra encapsulating classes, etc. :)
Ian
More information about the london.pm
mailing list