Discussion in 'Java' started by Roedy Green, Apr 27, 2014.

  1. Roedy Green

    Roedy Green Guest

    Is there a word that means "class or interface"?
    Roedy Green, Apr 27, 2014
    1. Advertisements

  2. Roedy Green

    markspace Guest

    It depends on context I think, but "type" might work. Classes and
    interfaces in Java are most often used to implement new types.
    "Super-type" and "sub-type" work to describe relationships between
    classes and interfaces.

    Java is kind of weird too that it explicitly has an interface type. C++
    uses pure virtual classes instead of "interfaces", so in that language
    they are all classes. It wouldn't be wrong to call an interface a class
    in Java. You can have a class object that is an interface, right? So
    interface is a sub-type of a class, a specific type of class with no
    method implementations.

    Classes can be abstract too, which is sort of like an interface,
    although some methods now may have an implementation.
    markspace, Apr 27, 2014
    1. Advertisements

  3. Genre has been used a lot for class. Different language variants of
    Bridge can be useful for Interface in an aesthetically pleasing sort of way.
    Richard Maher, Apr 27, 2014
  4. -> object

    In Java object is anything except for built-in value types, i.e. any
    class or interface.

    Note that this may not apply to other OO languages.

    Marcel Müller, Apr 27, 2014
  5. Roedy Green

    Qu0ll Guest

    "markspace" wrote in message
    Yes, "default methods" in interfaces with Java 8 certainly blurs the lines
    between abstract class and interface.

    And loving it,

    -Qu0ll (Rare, not extinct)

    [Replace the "SixFour" with numbers to email me]
    Qu0ll, Apr 27, 2014
  6. Roedy Green

    Qu0ll Guest

    "Marcel Müller" wrote in message

    -> object

    Huh? Isn't "object" an instance of a class or interface? I prefer "type"
    as suggested by markspace where object is an instance of a type (class or

    And loving it,

    -Qu0ll (Rare, not extinct)

    [Replace the "SixFour" with numbers to email me]
    Qu0ll, Apr 27, 2014
  7. Roedy Green

    Qu0ll Guest

    "lipska the kat" wrote in message
    I have never heard it referred to like that. Couldn't an "abstraction unit"
    be an entire group of classes/interfaces (and more typically so)?

    And loving it,

    -Qu0ll (Rare, not extinct)

    [Replace the "SixFour" with numbers to email me]
    Qu0ll, Apr 27, 2014
  8. It is. But the OP didn't say whether he talks about types or instances.

    In case of type the correct term is "reference type". Although this is
    somewhat uncommon in the Java world since all types except for some
    built-ins are reference types.

    Marcel Müller, Apr 27, 2014
  9. Roedy Green

    Qu0ll Guest

    "Marcel Müller" wrote in message
    He refers to "class or interface" which are most definitely types, not
    instances surely?

    And loving it,

    -Qu0ll (Rare, not extinct)

    [Replace the "SixFour" with numbers to email me]
    Qu0ll, Apr 27, 2014
  10. Roedy Green

    Jeff Higgins Guest

    Jeff Higgins, Apr 27, 2014
  11. Roedy Green

    Jeff Higgins Guest

    Jeff Higgins, Apr 27, 2014
  12. Roedy Green

    Roedy Green Guest

    In the sense I am looking for a generic term,
    a class is a some source code bracketed with class xxx { }
    an interface is some source code bracketed with interface xxx { }.

    One way of looking at it is it is a related group of methods.

    In many cases whatever you can do with a class reference you can do
    with an interface reference. You should not have spell out "class or
    interface" reference. In that case reference does mean both by

    If I were designing Java syntax from scratch, perhaps I would have
    would made interface a modifier, e.g. interface class cf. abstract
    class. Then we would not have the awkward implements vs extends

    I wonder if we could deprecate extends and make it a synonym for
    implements. If the defined is an interface, it implies the extends
    Roedy Green, Apr 27, 2014
  13. Yes the implementation of interfaces is different from that of classes.
    In fact this is the point where java already supports multiple
    inheritance. Accessing an interface requires another level of
    indirection because of this difference.
    This is exactly the way that C++ has gone. There the people claim that
    they need to write "public virtual Name" to implement an interface. And
    from time to time the "virtual" is missing, which leads to different and
    with respect to interfaces unexpected behavior. Others (accidentally)
    add data members to the interfaces which actually should not happen to
    Interfaces are used in Java quite often. Mainly to implement the PIMPL
    and/or the factory pattern.

    Marcel Müller, Apr 28, 2014
  14. Roedy Green

    Stefan Ram Guest

    Some Oracle products subsume »interface« under »class«. IIRC:

    1. The API documentation in the first lower-left pane of the
    HTML online version (at least in Java SE 6 and 7) has the
    title »all classes«, but then also lists interfaces under
    this title.

    2. When one disassembles byte code, interfaces are labelled
    »class«, interfaces are compiled into a ».class« file
    and are loaded by a »class loader«.

    The JLS 8 acknowledges this: »The binary format of a
    class or interface is normally the class file format«
    Stefan Ram, Apr 28, 2014
  15. Roedy Green

    Eric Sosman Guest

    In what way does an abstract method declaration in an abstract class
    differ from an abstract method declaration in an interface? ISTM that
    all abstract methods, wherever embedded, impose identical "contractual"
    requirements on their concrete implementations.

    As for "skeleton implementations" ...

    abstract class Abstract {
    abstract void setThing(Object obj);
    abstract Object getThing();

    interface Abstruse {
    void setThing(Object obj);
    Object getThing();

    There *is* a tiny skeletal shard to the former that the latter lacks:
    Abstract has a constructor, while Abstruse does not. But Abstract's
    constructor is pretty minimal: A mere bone splinter, not a structural
    element that can support weight and anchor muscles. I think that if
    you tried to argue that Abstract's trivial constructor amounted to an
    "implementation," you'd get at best a grudging "Well, *technically*"
    in response.

    By the way, one of the more intriguing (to me) uses of an abstract
    class is to "un-implement" something:

    abstract class Disinheritor {
    abstract String toString();

    A subclass of Disinheritor must provide its own toString() method, and
    cannot simply inherit Object's. So, does that make Disinheritor an
    "anti-skeleton implementation" or a "skeleton anti-implementation?" ;-)
    Eric Sosman, May 4, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.