4

I've been trying to learn some basic object oriented programming in Java. I was curious to know what the origin of the word interface is , if there is any documented description. Also I was trying to make sense of what it means by thinking of a generic concept as

A point where two systems, subjects, organizations, etc. meet and interact

I got this definition from google search. What are the two systems/entities that are interfacing? Or maybe my analogy used is inappropriate?. So far I think of it as a skeleton to define methods and property outlines.

3
  • that definition doesnt make any sense. Interfaces are what the name describes : INTERFACES -- templates which describe functionality and possibly interaction. In some languages (not Java), they even describe (!) storable / stored data. Commented Dec 5, 2014 at 19:46
  • @specializt that definition isn't right either. Commented Dec 5, 2014 at 19:50
  • so IT-reality "isnt right either" ? Hokay. Commented Dec 5, 2014 at 19:51

3 Answers 3

3

Software interfaces are one-way (though there are ways to pass the calling object as a reference to the callee), unlike Electrical connectors that interface both ways directly.

If you accept that difference in definition then the object 'implementing' the interface, is the object to be interfaced with. it allows other objects to connect to it using a well defined set of methods.

To compare it further to electronics, if 3 different types of devices all support audio-jacks, then all 3 devices essentially state: you can listen to me, I play audio. They could be very different devices (mp3 player, sonar, geiger counter) but they all clearly state: if you plug in a headphone, you can get sound out of me.

This is what an interface does in software. it states: I provide feature X, no matter what actual component I am.

so anything that implements the Map interface, can have .get(...) and .values() and .keySet() called on it. Anything that implements an AudioStream interface will yield an audiostream when called.

The object interfacing with the object supplying the interface can interact with this object in a predefined and well documented way. Ofcourse, how the object providing the interface actually makes it work can be completely different.

Sign up to request clarification or add additional context in comments.

Comments

3

An interface defines the common interface (hence the name :) multiple objects (of potentially different types) have in terms of method signatures. This is for consumption by other objects.

The JLS Chapter 9 states:

An interface declaration introduces a new reference type whose members are classes, interfaces, constants, and methods. This type has no instance variables, and typically declares one or more abstract methods; otherwise unrelated classes can implement the interface by providing implementations for its abstract methods. Interfaces may not be directly instantiated.

So this is more of a definition in terms of behavior than etymology.

Comments

1

The interface links your code (i.e. the class that implements your interface), and outside code. The outside code has access to your interface, but need not know your implementation.

The "two systems" (you asked for) are then the code implementing an interface and the code referencing it.

4 Comments

While true, this does not answer the question. The question was about the origin of the name, not its meaning.
Q: "What are the two systems/entities that are interfacing?", A: "The two systems are then your code, and outside code". I'm happy to delete my answer, but at least let me know what's wrong.
@kinbiko I reformulated it a bit. Looks perfectly fine to me now.
If you carefully read OP's question, there are too many mixed concepts there. OP's minding about Java interface and the generic concept of interface, which is not related to Java at all. And your answer doesn't provide a solution for either of them. And no, an interface doesn't link any code at all, that's not the work of interface.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.