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

OO inheritance in a hacker style

Thread Next
Dmitry Dorofeev
January 28, 2004 17:09
OO inheritance in a hacker style
Message ID:
Hi all.
Sorry if this idea|question has been discussed or has name which i don't know about.

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.


Class a {
method getX;
method getY;
method size;
method area;
method move;

I'd like to write

Class myclass : a {
forget method area;
forget method move;
method put;

so methods getX, getY, size will be 'inherited'.
Methods 'area' and 'move' will be not present in myclass at all!
$a = new myclass;

will return an error. 
At some level of inheritance methods area() and move() may be reimplemented again if required.

I see few benefits
1. Much more flexible to build what programmers need. Becouse we have both 'joining' and 'breaking' around us in real life.
2. Inheritance diagrams may become less in size, showing only what programmer use or need in classes.
3. probably there are some optimization possibilities (especially for properties)

i see some drawbacks
1. kills traditional OO mainstream, theory and books
2. hard to keep track both for 'added' methods and for 'killed' methods in mind.
3. hard to know if 'killed' method called from the other methods in the class. But that may be
	not a problem if we just declare forget blah, without affecting run-time.

I am very interested what Perl gurus think about it. Even if you consider this as stupidiest idea ever.
Which is probably true :-)

-Dmitry Dorofeev.

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