develooper Front page | perl.perl6.language | Postings from January 2004

Re: OO inheritance in a hacker style

Thread Previous
From:
Michael G Schwern
Date:
January 28, 2004 18:48
Subject:
Re: OO inheritance in a hacker style
Message ID:
20040129024106.GA15827@localhost.comcast.net
On Wed, Jan 28, 2004 at 03:18:24PM +0300, Dmitry Dorofeev wrote:
> I am not very good at OO but I tried at least 2 times to develop with it 
> though :-)
> Last time it was Java. The problem is that when i going to use some 
> 'standard' class
> or 3d party class i'd rather to cut off all unnecessary methods (and may be 
> even properies!),
> then adding my own. I know it kills inheritance but it is much more to my 
> Perl habit of hacking code.

There's little benefit to explicitly stubbing out inherited methods you 
don't plan to use, just don't use them.  Its not worth screwing up
the language's inheritence model with an explicit way to have a subclass 
not implement its parent's interface.

I suspect that if you find yourself only needing a small fraction of your
parent's interface often, inheritence might not be the right thing.  Consider
delegation instead.


-- 
Michael G Schwern        schwern@pobox.com  http://www.pobox.com/~schwern/
You're more radiant than a memory of breathtaking ecstasy.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About