| Interface (computer Science) |
Article Index for Interface |
Website Links For Interface |
Information AboutInterface (computer Science) |
|
An interface defines the communication boundary between two entities, such as a piece of software, a hardware device, or a User . It generally refers to an Abstraction that an entity provides of itself to the outside. This separates the methods of external communication from internal operation, and allows it to be internally modified without affecting the way outside entities interact with it, as well as provide Multiple Abstractions of itself. It may also provide a means of translation between entities which do not speak the same language, such as between a human and a computer. Because interfaces are a form of Indirection , some additional overhead is incurred versus direct communication. The interface between a human and a computer is called a User Interface . Interfaces between hardware components are Physical Interface s. This article deals with ''software interfaces'' which exist between separate Software Component s and provide a programmatic mechanism by which these components can communicate. INTERFACES IN PRACTICE A piece of software is provided 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 (See Information Hiding ). The types of access that interfaces provide between software components can include: Constant s, Data Type s, types of Procedure s, Exception specifications and Method Signature s. In some instances, it may be useful to define Variable s as part of the interface. It often also specifies the functionality of those procedures and methods, either by Comment s or (in some experimental languages) by formal logical assertions. The interface of a software module 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 (which can be referred to as a ''client'' to ''A'') that interacts with is forced to do so ''only'' through the interface. One practical advantage of this arrangement is that replacing the implementation of by another one that meets the same specifications of the interface should not cause to fail — as long as its use of complies with the specifications of the interface (See also Liskov Substitution Principle ). USES OF INTERFACES The concept of interface is the cornerstone of Modular programming, a forerunner and a standard ingredient of Object-oriented Programming . In object-oriented programming, an object's interface consists of a set of methods that the object must respond to. Note that the object does not make its instance variables a part of its interface - these are typically accessed by means of Accessor Method s. Some object-oriented programming languages mandate that the interface to the object be specified to the compiler separately from the implementation of that object, whilst others relax the requirement. For example, a class in a programming language such as Objective-C consists of its interface, specified in a header file, and the implementation in the source file. Because of the Dynamically Typed nature of Objective-C, one can send messages to any object, and the interface to the class becomes important as it specifies the methods the class responds to. Interfaces were historically derived from the Header File s of the C Programming Language by restricting their syntactic context and contents, and making them a part of the language semantics (as opposed to a mere Preprocessor feature). The Java Programming Language takes a different approach to the concept of the interface normally existing in other object-oriented programming languages (i.e. that the interface specified is the interface to the class), in that an interface specifies a set of methods which implement some specific functionality, common to a set of classes. See Protocol (object-oriented Programming) . Some programming languages (e.g. D , Java , Logtalk ) allows the definition of ''interface hierarchies''. This allows easy definition of e.g. both minimal and extended versions of an interface. Some programming languages (e.g. Logtalk ) support ''private'' and ''protected'' implementation of an interface. Thus, the (public) methods declared in an interface can easily become private or protected methods of a class implementing the interface. The Eiffel language includes in the interface of a class its Invariants and the Pre- and Postcondition s of the methods of the class. This is essential to the methodology of Design By Contract , and may be regarded as an extension of the conditions imposed by the types of the arguments. These rules may be specified in the implementation of a class or in an ancestor which may leave the methods unimplemented. They are extracted by language processors to provide an interface view in the Development Environment and to generate run-time Assertions (checks) in debug versions. The language also ensures that derived classes obey the contracts of their ancestors. Supporting Languages Certain programming languages have different methodologies for allowing the construction of interfaces. In general, any programming language can implement an interface, but the following Programming Language s provide specific interface ''constructs'' of some kind or another:
SEE ALSO
|
|
|