vocabulary

M

markspace

Is there a word that means "class or interface"?

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.
 
R

Richard Maher

Is there a word that means "class or interface"?
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.
 
M

Marcel Müller

Is there a word that means "class or interface"?

-> 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
 
Q

Qu0ll

"markspace" wrote in message
Classes can be abstract too, which is sort of like an interface, although
some methods now may have an implementation.

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

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
(e-mail address removed)
[Replace the "SixFour" with numbers to email me]
 
Q

Qu0ll

"Marcel Müller" wrote in message

Is there a word that means "class or interface"?

-> 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
interface).

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
(e-mail address removed)
[Replace the "SixFour" with numbers to email me]
 
Q

Qu0ll

"lipska the kat" wrote in message
Abstraction unit

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)
_________________________________________________
(e-mail address removed)
[Replace the "SixFour" with numbers to email me]
 
M

Marcel Müller

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 interface).

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
 
Q

Qu0ll

"Marcel Müller" wrote in message
It is. But the OP didn't say whether he talks about types or instances.

He refers to "class or interface" which are most definitely types, not
instances surely?

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
(e-mail address removed)
[Replace the "SixFour" with numbers to email me]
 
R

Roedy Green

He refers to "class or interface" which are most definitely types, not
instances surely?

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
default.

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
distinction.

I wonder if we could deprecate extends and make it a synonym for
implements. If the defined is an interface, it implies the extends
meaning.
 
M

Marcel Müller

It seems to me that the only reason Java has both Abstract Class and
Interface definitions is to sidestep having to implement multiple
inheritance:

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.
if multiple inheritance was supported there would be no
difference between them.

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.
That said, I seldom use Interface definitions
but find the distinction can be useful.

Interfaces are used in Java quite often. Mainly to implement the PIMPL
and/or the factory pattern.


Marcel
 
S

Stefan Ram

Marcel Müller said:
Yes the implementation of interfaces is different from that of classes.

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«
 
E

Eric Sosman

Martin said:
It seems to me that the only reason Java has both Abstract Class and
Interface definitions is to sidestep having to implement multiple
inheritance

FWIW, I disagree with this entirely.

For me, as for [some] others, interfaces are an expression of a /contract/ --
they are used to communicate guarantees/requirements between producers and
consumers of APIs.

Abstract classes, on the other hand, are nothing to do with contractual
communication between programmers. They are skeleton implementations.
[...]

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?" ;-)
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,999
Latest member
MakersCBDGummiesReview

Latest Threads

Top