Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Judge a book by it's author

by robot_tourist (Hermit)
on Sep 01, 2005 at 12:46 UTC ( [id://488364]=note: print w/replies, xml ) Need Help??


in reply to Judge a book by it's author
in thread Advanced Perl Programming, 2nd edition

Inheritance is an essential part of any Object Oriented Programming language. Some languages implement it better than others, some programmers implement it better than others, but I don't know of a better way (although I have been out of university for a couple of years now).

How can you feel when you're made of steel? I am made of steel. I am the Robot Tourist.
Robot Tourist, by Ten Benson

Replies are listed 'Best First'.
I don't think inheritance is essential
by systems (Pilgrim) on Sep 01, 2005 at 13:17 UTC
    First not all object systems implement or provide inheritance for example check snit
    In my understanding inheritence serve two purposes
    1. Gives you a mean to say that an object have more than one type (play more than one role, thus inheritance and multiple inheritance), this is only useful if you ever need to test an object type, which as far as I only required by static languages, and usually forwned upon in dynamic languages
    2. Give a default value for the method the object inherited (unless you are inheriting from an abstract class)
    I think you find can other ways to achive both requirements without inheritance. Which makes inheritance an implementation detail, a technique not a requirement.
    I prefer to focus on the requirement, and consider the different ways and alternatives to achieve it.

      IMO your point number two is pretty fundamental to object orientation and is a very good one-line synopsis, you take a class and extend it by adding functionality, but keeping all the stuff you don't want to re-invent. And it gives you a nice tree to draw when you are designing your system.

      Personally, I can't think of a good reason not to use inheritance.

      How can you feel when you're made of steel? I am made of steel. I am the Robot Tourist.
      Robot Tourist, by Ten Benson

        Personally, I can't think of a good reason not to use inheritance.

        I can. It encourages code reuse along the wrong lines, caring more about position in an arbitrary (and quite possibly wrong hierarchy) than about the capabilities of the class.

        That's why Perl 6 encourages the use of roles.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://488364]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2025-03-27 17:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (70 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.