- Interface (computing)
In the field of computer science, an interface is a tool and concept that refers to a point of interaction between components, and is applicable at the level of both hardware and software. This allows a component, whether a piece of hardware such as a graphics card or a piece of software such as an Internet browser, to function independently while using interfaces to communicate with other components via an input/output system and an associated protocol.
In addition to hardware and software interfaces, a computing interface may refer to the means of communication between the computer and the user by means of peripheral devices such as a monitor or a keyboard, an interface with the Internet via Internet Protocol, and any other point of communication involving a computer.
Hardware interfaces exist in computing systems between many of the components such as the various buses, storage devices, other I/O devices, etc. A hardware interface is described by the mechanical, electrical and logical signals at the interface and the protocol for sequencing them (sometimes called signaling). A standard interface, such as SCSI, decouples the design and introduction of computing hardware, such as I/O devices, from the design and introduction of other components of a computing system, thereby allowing users and manufacturers great flexibility in the implementation of computing systems. Hardware interfaces can be parallel where performance is important or serial where distance is important.
A software interface may refer to a range of different types of interface at different "levels": an operating system may interface with pieces of hardware, applications or programs running on the operating system may need to interact via streams, and in object oriented programs, objects within an application may need to interact via methods.
Software interfaces in practice
A piece of software provides access to computer resources (such as memory, CPU, storage, etc.) by its underlying computer system; the availability of these resources to other software can have major ramifications—sometimes disastrous ones—for its functionality and stability. A key principle of design is to prohibit access to all resources by default, allowing access only through well-defined entry points, i.e. interfaces.
The types of access that interfaces provide between software components can include: constants, data types, types of procedures, exception specifications and method signatures. In some instances, it may be useful to define public variables as part of the interface. It often also specifies the functionality of those procedures and methods, either by comments or (in some experimental languages) by formal logical assertions and preconditions.
The interface of a software module A is deliberately kept separate from the implementation of that module. The latter contains the actual code of the procedures and methods described in the interface, as well as other "private" variables, procedures, etc.. Any other software module B (that can be referred to as a client to A) that interacts with A is forced to do so only through the interface. One practical advantage of this arrangement is that replacing the implementation of A by another one that meets the same specifications of the interface should not cause B to fail—as long as its use of A complies with the specifications of the interface. (See also Liskov substitution principle.)
Software interfaces in object oriented languages
In object-oriented languages the term "interface" is often used to define an abstract type that contains no data, but exposes behaviors defined as methods. A class having all the methods corresponding to that interface is said to implement that interface. Furthermore, a class can implement multiple interfaces, and hence can be of different types at the same time.
An interface is hence a type definition; anywhere an object can be exchanged (in a function or method call) the type of the object to be exchanged can be defined in terms of an interface instead of a specific class. This allows later code to use the same function exchanging different object types; hence such code turns out to be more generic and reusable.
Usually a method in an interface cannot be used directly; there must be a class implementing that object to be used for the method invocation. For example, one can define an interface called "Stack" that has two methods:
pop()and later implement it in two different versions, say, FastStack and GenericStack—the first being faster, but working with a stack of fixed size, and the second using a data structure that can be resized, but at the cost of somewhat lower speed.
This approach can be pushed to the limit of defining interfaces with a single method; e.g. the Java language defines the interface Readable that has the single
read()method and a collection of implementations to be used for different purposes, among others: BufferedReader, FileReader, InputStreamReader, PipedReader, and StringReader; or even less, marker interfaces like Serializable contain virtually nothing.
In its purest form, an interface (like in Java) must include only method definitions and constant values that make up part of the static interface of a type. Some languages (like C#) also permit the definition to include properties owned by the object, which are treated as methods with syntactic sugar, but no constants (in contrast to Java), constructors, destructors, fields, nested types, or operators.
Programming against software interfaces
The use of interfaces allows implementation of a programming style called programming against interfaces. The idea behind this is to base the logic one develops on the sole interface definition of the objects one uses and not to make the code depend on the internal details. This allows the programmer the ability to later change the behavior of the system by simply swapping the object used with another implementing the same interface.
Pushing this idea to the limit one can introduce the inversion of control that means leaving the context to inject the code with the specific implementations of the interface that will be used to perform the work.
- ^ a b Blaauw, Gerritt A.; Brooks, Jr., Frederick P., "Chapter 8.6, Device Interfaces", Computer Architecture-Concepts and Evolution, Addison-Wesley, pp. 489–493, ISBN 0-201-10557-8 See also: Patterson, David A.; Hennessey, John L., "Chapter 8.5, Interfacing I/O Devices to the Processor, Memory and Operating System", Computer Organization and Design - The Hardware/Software Interface, Third Edition, Morgan Kaufmann, pp. 588–596, ISBN 1-55860-604-1
- ^ Bill Venners (2005-06-06). "Leading-Edge Java: Design Principles from Design Patterns: Program to an interface, not an implementation - A Conversation with Erich Gamma, Part III". http://www.artima.com/index.jsp: artima developer. http://www.artima.com/lejava/articles/designprinciples.html. Retrieved 2011-08-03. "Once you depend on interfaces only, you're decoupled from the implementation. That means the implementation can vary, and that's a healthy dependency relationship. For example, for testing purposes you can replace a heavy database implementation with a lighter-weight mock implementation. Fortunately, with today's refactoring support you no longer have to come up with an interface up front. You can distill an interface from a concrete class once you have the full insights into a problem. The intended interface is just one 'extract interface' refactoring away. ..."
- ^ "Performance improvement techniques in Serialization". http://www.precisejava.com/: Precise Java. http://download.oracle.com/javase/7/docs/api/java/io/Serializable.html. Retrieved 2011-08-04. "We will talk initially about Serializable interface. This is a marker interface and does not have any methods."
- ^ Mössenböck, Hanspeter (2002-03-25). "Advanced C#: Interfaces: Syntax". http://ssw.jku.at/Teaching/Lectures/CSharp/Tutorial/: Institut für Systemsoftware, Johannes Kepler Universität Linz, Fachbereich Informatik. p. 17. http://ssw.jku.at/Teaching/Lectures/CSharp/Tutorial/Part2.pdf. Retrieved 2011-08-04.
Wikimedia Foundation. 2010.
Look at other dictionaries:
interface — noun 1. (chemistry) a surface forming a common boundary between two things (two objects or liquids or chemical phases) (Freq. 3) • Derivationally related forms: ↑interfacial • Topics: ↑physical chemistry • Hypernyms: ↑ … Useful english dictionary
interface — ▪ I. interface in‧ter‧face 1 [ˈɪntəfeɪs ǁ ər ] noun [countable] 1. the point at which two subjects, events etc are connected with each other or have an effect on one another: interface between • The next chapter discusses the interface between… … Financial and business terms
computing — noun 1. the procedure of calculating; determining something by mathematical or logical methods • Syn: ↑calculation, ↑computation • Derivationally related forms: ↑computational (for: ↑computation), ↑compute … Useful english dictionary
Computing platform — A computing platform includes some sort of hardware architecture and a software framework (including application frameworks), where the combination allows software to run. Typical platforms include a computer s architecture, operating system,… … Wikipedia
interface — [[t]ɪ̱ntə(r)feɪs[/t]] interfaces, interfacing, interfaced 1) N COUNT The interface between two subjects or systems is the area in which they affect each other or have links with each other. ...a witty exploration of that interface between… … English dictionary
Computing π — Similarly, the more complex approximations of π given below involve repeated calculations of some sort, yielding closer and closer approximations with increasing numbers of calculations.Continued fractionsBesides its simple continued fraction… … Wikipedia
Computing — For the formal concept of computation, see computation. For the magazine, see Computing (magazine). For the scientific journal, see Computing (journal). A difference engine: computing the solution to a polynomial function … Wikipedia
Interface metaphor — An Interface metaphor is a set of user interface visuals, actions and procedures that exploit specific knowledge that users already have of other domains. The purpose of the interface metaphor is to give the user instantaneous knowledge about how … Wikipedia
interface — n. /in teuhr fays /; v. /in teuhr fays , in teuhr fays /, n., v., interfaced, interfacing. n. 1. a surface regarded as the common boundary of two bodies, spaces, or phases. 2. the facts, problems, considerations, theories, practices, etc., shared … Universalium
Interface Design — Interfacedesign (dt.: Schnittstellendesign) ist eine Disziplin des Designs, die sich mit der grafischen Gestaltung von Benutzeroberflächen zwischen Mensch und Maschine beschäftigen. Dafür werden die Bedingungen, Ziele und Hindernisse dieser… … Deutsch Wikipedia