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

Re: OO inheritance in a hacker style

Thread Previous
Michael G Schwern
January 28, 2004 18:48
Re: OO inheritance in a hacker style
Message ID:
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
You're more radiant than a memory of breathtaking ecstasy.

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About