Okay, the problem then is that we've got different definitions of what an interface is. For me, coming from C++ and Java, the technical definition of an interface is an abstract superclass that provides only static data members, abstract method declarations, and that indicates an is-a relationship. To quote from Java in a Nutshell: "When you define an interface, you are creating a new reference type, just as you are when you define a class." (p. 112).

What you're talking about is behavior without association to a reference type. You essentially want a list of things that an object can do with its type information stripped away. In this sense, bart's suggestion to use can seems very close to what you want, as dws's astute observation that different classes may "mean" different things by similarly named methods is only relevant insofar as you're concerned with is-a relationships and getting one particular class-specific behavior. If your Test::MockObject is the prototypical application for this idea then I think using can is fine, as the objective there is, inasmuch as I can gather from a quick perusal, to isolate the code you're testing from other dependencies. This is a great idea, and it's much better than the one-off approach I've sometimes had to use in temporarily redefining methods just to report back some placeholder information. Nonetheless, I must cling to the belief for the time being at least that "real" code going into production or publication would suffer greatly in terms of maintainability from this sort of thing. And in that sense fixing the object model is almost always going to be preferrable to warping inheritance chains.

Due to the substantial precedence for associating interfaces with reference types, I think a different term would be helpful here. It sounds like what you want is shorthand for grouping a set of methods together into a set, but one not unified by type. Maybe "possible behaviors" would suffice?


In reply to Re: Re: Re: Re: Re: Class::Interface -- isa() Considered Harmful by djantzen
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.