Inheritance is by no means the only way of constructing classes. I'm looking for a scheme by which I can say "this object can receive these messages". I don't want it tied to inheritance, except that I want subclasses to be marked as implementing their parents' interfaces.

I think Java got it wrong in this case.

My example (which is not great, and that leads to the confusion), I imagine that the Arcade interface has a couple of methods: collect_quarters() and play_annoying_dance_music(). Whenever a Person walks by, it should play the annoying music. Whenever a FranchiseOwner or Hoodlum walks by, he should be able to collect quarters. It oughtn't matter if the Arcade is alone on the street, in a Mall, or in the Airport. If the actor is near something that implements the Arcade interface, he should have the option of listening to the annoying dance music or collecting quarters.

If the only option I have is inheritance, that power is lost to me. It's as if I wanted to make a Car that could throw_hubcap(), so Car had to inherit from Wheel. What happens when I want HoverCar?


In reply to Re: Re: Class::Interface -- isa() Considered Harmful by chromatic
in thread Class::Interface -- isa() Considered Harmful by chromatic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.