473,589 Members | 2,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

On Java's Interface (the meaning of interface in computer programing)

On Java's Interface

Xah Lee, 20050223

In Java the language, there's this a keyword “interface” .

In a functional language, a function can be specified by its name and
parameter specs. For example:
f(3)
f(3, [9,2])
f("some string")

are usage examples of 3 functions all having the same name, but having
different number and type of arguments. In this way, a function is
essentially known to outsiders by its name and parameter specs. The
gist in this concept is that the user don't need to know the
implementation details of the function. All she needs to know is the
function's name, and parameter specs and return value spec. (and of
course what the function is supposed to do.) In this way, interface
and implementation are separated. The implementation can change or
improve anytime, and users don't need to know.

In Java, the above concept of function name and parameter spec is
called a method's signature.

For another example, usually a program needs to talk to another
software such as a database software. The database software may have a
set of functions for the purpose of communicating to other software.
In essence, making the database useful to other software. Such a list
of function spec is often called API, which stands for Application
Programing Interface.

The API terminology is abused by the marketing-loving Sun Microsystems
by calling the Java language's documentation as “The Java API”, even
though Java the language and its paraphernalia of libraries and
hardware-emulation system (all together jargonized as “the Java
Platform”) isn't a Application nor Interface. (a API implies that
there are two disparate entities involved, which are allowed to
communicate thru it. In the case of “The Java API”, it's one entity
talking to itself.).

In general, the interface concept in programing is a sort of
specification that allows different entities to call and make use of
the other, with the implication that the caller need not know what's
behind the facade.

In the Object Oriented Programing Paradigm, a new concept arose, that
is the “interface” aspect of a class.

As we've seen, a function has parameter spec that is all there it is a
user needs to know for using it. In Java, this is the method's
“signature” . Now, as the methodology of the OOP experience multiplies,
it became apparent that the interface concept can be applied to
Classes as well. Specifically: the interface of a class is the class's
methods.

This concept is then turned into a OOP machinery, in hope of
extracting usefulness in software engineering. That is to say, now in
the Java language, a programer can actually write a piece of code,
whose sole purpose is to define what methods and variables a class
contains. This, is done with the keyword “interface” . Once a interface
is defined, other classes can say which interfaces they implement, so
that if class C implement interface I, then programers don't need to
know the details about C. All they need to know is the interface I.
(which specifies all the methods, constructors, variables, a class
must have.)

(the Java's interface, is essentially the “signature” of a class, in
Java's own jargon.)

A programer may ask, what's the big deal anyway? Since in Java,
classes are well documented anyway. What difference does it make to
know the documentation of C versus the documentation of interface for
C?

The thing about interface in Java is that the complexity grows. A Java
interface, can be inherited, just as classes. The idea is that
interfaces can also form a hierarchy just like classes.

In pure OOP such as Java, the object entities used to solve computing
problems are thought to form a relation as of a tree, thus we have the
class hierarchy. In a similar way, it is thought that interface, can
also form a hierarchy fruitfully. A good example is the list data
type. The explanation follows.

In computing languages, often there's a data concept variously known
as lists, aggregate, sequences, array, vector, tuple, set, matrix,
trees... The basic idea is that it is just a list of things. This list
may not allow repetitions, elements may be lists themselves, may have
certain dimension stipulations (e.g. matrix), may have certain
computational properties such as speed of retrieving a element or
adding a element or memory footprint... etc and so on. Different
requirement and different computational properties have given them
various names to go by. One can however organize them by the interface
perspective. In Java, they are known as Collection, and all have the
interface of Collection. (See http://java.sun.com/j2se/1.5.0/docs/...ollection.html
http://java.sun.com/docs/books/tutor...ces/index.html
)

Consider a Set and List. One does not allow repetitions, while the
other allows. Other than that, both concepts are the same. They both
need methods like adding elements, deleting, inserting, sorting etc.
Therefore, from interface point of view, they share a parent. In Java,
both Set and List are interfaces, inherited from the parent interface
Collection.

So now, in Java, we have two hierarchies of separate category: Classes
and Interfaces. The Classes hierarchy is one single giant tree.
However, the interfaces are not all together as one tree. They are
more like forests, of many trees. It is important to remember that
interfaces and classes are separate entities. A class can implement a
interface. A interface can never inherit from a class.

In Java, it so happens that a class can implement more than one
interfaces. When a class C implements interfaces I1 and I2, C is
guaranteed to have all methods declared by interface I1 and I2. For
example, in Java, class Integer has interfaces Comparable and
Serializable. And the class ArrayList has these interfaces: Cloneable,
Collection, List, RandomAccess, Serializable.

The interface in Java, from a simple useful idea, has mutated into a
incomprehensibl e complexity.

In Java, Interface is no longer the sole thing a programer needs to
know about a class or function. It is no longer a concept that
separates a function's user spec from implementation detail.

For example, the ArrayList class has these interfaces: Cloneable,
Collection:List , RandomAccess, Serializable. As one can infer from the
names, they are more about what properties ArrayList has, than a
syntax facade that hides implementation irrelevances.

For example, see the Java documentation on these interfaces: •
interface RandomAccess http://java.sun.com/j2se/1.5.0/docs/...domAccess.html

• interface Serializable http://java.sun.com/j2se/1.5.0/docs/...ializable.html

• interface Comparable http://java.sun.com/j2se/1.5.0/docs/...omparable.html

One can see that these “interfaces are really not interface in
nature, but properties. One might ask, in “interfaces suchas
RandomAccess that doesn't have a single variable or method, in what
technical definition that a class is said to satisfy such interfaces?
And, given the existence of these property-like interfaces, can a
programer define their own arbitrary computational property contract?
For example, suppose i want a property ConstantTime for the classes in
game i'm developing. Once i declared a class to have “interface”
ConstantTime, apparently my class is not going to magically become
constant time. How do i define arbitrary properties to the compiler,
and how's the compiler going to check? The following are the answers.
20050224

Java's Interface has mutated so much from the interface concept that
it also functions as a pure label. If a interface does not have any
variables or methods, any class can declare it as a interface. There
is no restraint whatsoever. For example, the RandomAccess interface in
Java does not have any variables or methods. Any class can declare it
as a interface, randomly accessible or not. When interface is used as
a label, it is called a “marker interface” by the Java documentation.
For example, see http://java.sun.com/j2se/1.5.0/docs/...domAccess.html

Because the multi-inheritance nature of Java interface, and its double
role as a label, it no longer function as a communication facade that
is the meaning of interface. If a Java class have interfaces A, B, C,
D, E, one cannot be sure just exactly what methods or variables the
class have. (it will be a union of them, and some of them do not serve
any function with respect to the language.) Further, using interface
as a inert label to indicate computational properties (e.g.
RandomAccess) is a egregious incompetence in the design of a language
for computation. The gist of the problem is that it is a piece of
mathematical irrelevance in the language. As a labeling mechanism in a
language, for the possible benefit from the software engineering
perspective, then it should not be designed as part of the Class
Interface, since labeling and programing interfaces are semantically
disparate.
On the Inanity of Standard Java Tutorials

The standard Java tutorials out there are often inane, in that none of
them actually tried to teach what the language actually manifestly do,
but instead, often talk in some purportedly good engineering
perspective.

For a incomprehensibl e metaphysical intro to interface using bicycle,
see this page of the Official Java Tutorial:
http://java.sun.com/docs/books/tutor...interface.html.
For a more detailed account of Interface using baffling financial
stocks, see this page of the Official Java Tutorial:
http://java.sun.com/docs/books/tutor...interface.html.
(the official Java Tutorial has went into major changes in 2006. For
the version of the above two pages, see local copy as of 2005

PS the official Java tutorial thru its update history has changed its
stance about what's a interface:

before 2005:
Definition: An interface is a named collection of method definitions
(without implementations ). An interface can also declare constants.

sometimes after 200501:
Definition: An interface is a device that unrelated objects -- objects
that are not related by class hierarchy -- can use to interact with
each other. An object can implement multiple interfaces.

Complexer and complexer. Note its use of the word “device”.

In its current incarnation (as of 2006-08-14) of the tutorial
http://java.sun.com/docs/books/tutor...ndI/index.html,
interface is not particularly given a definition.

References:
Java lang spec, 2nd ed, 8.4.2 on Method Signature,
http://java.sun.com/docs/books/jls/s...doc.html#38649
Official Java documentation page for 1.5.0, where it calls itself API.
http://java.sun.com/j2se/1.5.0/docs/...w-summary.html

------------
This post is archived at:
http://xahlee.org/java-a-day/interface.html

Xah
xa*@xahlee.org
http://xahlee.org/

Mar 21 '07 #1
15 2779
No.

Mar 21 '07 #2
Lew
Xah Lee wrote:
In a functional language, a function can be specified by its name and
Are you sure you know what a "functional language" is?
parameter specs. For example:
f(3)
f(3, [9,2])
f("some string")
This is not really "typical" syntax for a functional language. LISP, for
example, has the "function name" as an element of a list. (Some might argue
that LISP isn't exactly a functional language.)

Also, since you are commenting on Java, you should use "Java-like" syntax
rather than "[9,2]". What is "[9,2]" intended to represent? The range of
integers decreasing from 9 to 2, inclusive?
For another example, usually a program needs to talk to another
software such as a database software.
Interesting use of the word "software".
In essence, making the database useful to other software.
This is not a sentence.
Such a list of function spec is often called API, which stands for Application
Programing Interface.
"an API"
The API terminology is abused by the marketing-loving Sun Microsystems
by calling the Java language's documentation as “The Java API”, even
though Java the language and its paraphernalia of libraries and
hardware-emulation system (all together jargonized as “the Java
Platform”) isn't a Application nor Interface. (a [sic] API implies that
there are two disparate entities involved, which are allowed to
communicate thru [sic] it. In the case of “The Java API”, it's one entity
talking to itself.).
This is incorrect in every factual detail. And what's with the editorial
comment in the middle of the exposition ("marketing-loving", "jargonized ")?
How does that help explain the concepts, even if it were supportable by the
evidence?

Sun calls the API documentation "the Java API documentation", not "the Java
API", and not the language documentation, and the API is indeed an interface.
An API need not be, and quite often is not, an application - being an
application is in no wise part of being an API. And why in the world did you
capitalize "Applicatio n" and "Interface" ?

It's "an API", not "a API". It's "through", not "thru".

The statement about an "API" having to do with "two disparate entities" makes
no sense. There is certainly nothing in the API that one can characterize as
"one entity talking to itself". What "entities" do you imagine are involved?
In general, the interface concept in programing is a sort of
specification that allows different entities to call and make use of
the other [sic], with the implication that the caller need not know what's
behind the facade.
There is no antecedent for "the other", and you haven't defined "entities",
and the word "interface" has a number of meanings "in general ... in
programming". You should focus on the Java meaning (and your grammar).
In the Object Oriented Programing Paradigm [sic], a new concept arose, that
is the “interface” aspect of a class.
Historical citation needed. And an interface is not an "aspect of a class".
As we've seen, a function has parameter spec [sic] that is all there it [sic] is a
user needs to know for using it. In Java, this is the method's
“signature” . Now, as the methodology of the OOP experience multiplies,
it became apparent that the interface concept can be applied to
Classes as well. Specifically: the interface of a class is the class's
methods.
OK, I've had enough. I'd say you need a good editor to clean up the grammar,
but then all you'd have is a better-written incorrect explanation.

-- Lew
Mar 21 '07 #3
Don't Feed The Trolls :-)

Mar 21 '07 #4
Lew
Dr. Who wrote:
Don't Feed The Trolls :-)
But, but - you fed me!?

Oh, wait, I'm only a half-troll, on my father's side.

Thanks for the attention.

Kidding aside, a post like the OP's is useful as an exercise in finding the
errors, grammatical and factual. It's like a math book I had in my first year
at university. Its theorems were riddled with typographical errors, mixing the
us, vs and ws all around. I'd be up for hours figuring out if I was wrong or
the book was wrong. In the end it gave me a lot more exercise than the
homework problems did.

Also, I wanted to protect the innocent.

We could put up a contest - whoever finds and corrects the most errors in the
post wins. Ties broken by the quality of the correct explanations. Incorrect
explanations count against the entry.

-- Lew
Mar 21 '07 #5
On 21 Mar, 19:11, Lew <l...@nospam.le wscanon.comwrot e:
Dr. Who wrote:
Don't Feed The Trolls :-)

But, but - you fed me!?
[blah]
>
We could put up a contest - whoever finds and corrects the most errors in the
post wins. Ties broken by the quality of the correct explanations. Incorrect
explanations count against the entry.

-- Lew
Or you could stop feeding the trolls.

Mar 22 '07 #6

Lew <le*@nospam.lew scanon.comwrite s:
Xah Lee wrote:
>In a functional language, a function can be specified by its name and

Are you sure you know what a "functional language" is?
>parameter specs. For example:
f(3)
f(3, [9,2])
f("some string")

This is not really "typical" syntax for a functional language. LISP,
for example, has the "function name" as an element of a list. (Some
might argue that LISP isn't exactly a functional language.)

And nobody really cares, since syntax doesn't make a functional language anyways ...

Regards -- Markus
Mar 22 '07 #7
Lew
Jim Burton wrote:
Or you could stop feeding the trolls.
Does not apply. The OP was not being trollish, they were being spammish.

-- Lew
Mar 22 '07 #8
Lew
Jim Burton wrote:
Or you could stop feeding the trolls.
People need to stop saying that. The original post was a detailed if incorrect
exposition of Java information. How in the world do you rate that trollish?

I have absolutely no reason to rate the OP as a troll or their post as trollish.

-- Lew
Mar 22 '07 #9
Lew <le*@nospam.lew scanon.comwrite s:
Jim Burton wrote:
>Or you could stop feeding the trolls.

Does not apply. The OP was not being trollish
You obviously don't know Xah. He's been doing this for years, cross-
posting to various language groups trying to start an argument between
them. He even brags about being a troll on his web site.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
Mar 22 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

73
7956
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities as a standard portable part of the core language, the LISP package, and the java.lang package, respectively. Both have big integers, although only LISP has rationals as far as I can tell. Because CL supports keyword arguments, it has a wider range...
11
9231
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
1
9613
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
0
2501
by: YellowFin Announcements | last post by:
Introduction Usability and relevance have been identified as the major factors preventing mass adoption of Business Intelligence applications. What we have today are traditional BI tools that don't work nearly as well as they should, even for analysts and power users. The reason they haven't reached the masses is because most of the tools are so difficult to use and reveal so little
0
15399
by: r035198x | last post by:
Overriding therefore allows you to use the same method name to refer to differently implemented methods. Here is an example using the famous shapes example. class Shape { public Shape() { } public double getArea() { return 5.0; }
1
1600
by: molaie | last post by:
hello I need a source code program student with languge socket programing with java that: 1- for a car parking 2-that keep number enter & exit cars 3-and report no 2 4-and login thanks
1
1707
by: kavir | last post by:
hello I need a source code program(socket programing with java) that: 1- for a car parking 2-send&save car details to server DB 3-Enter & exit & perice 4-report 5-login
0
3886
by: r035198x | last post by:
Inheritance We have already covered one important concept of object-oriented programming, namely encapsulation, in the previous article. These articles are not articles on object oriented programming but on Java programming but I will cover all the important aspects of object oriented programming as Java has full support for object-oriented programming even though it is not a fully object-oriented language (in the sense that you can write...
8
2708
intruderX
by: intruderX | last post by:
When programing robots with java, how they program hardware with java? Can java do the port programming? Or it is done in some other way? for an example... 1). A basic O/S is running to work with hardware. 2). JVM runs on that O/S. 3). A Java program is running on the JVM, and it(JAVA) is used for the programming, as it become more user friendly to the programmers. I need to know whether we can program hardware with just JAVA, without...
0
7931
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
7865
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8360
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8224
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5731
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5399
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3889
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1198
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.