In computing, an interface is a shared boundary across which two or more separate components of a computer system exchange information. The exchange can be between software, computer hardware, peripheral devices, humans, and combinations of these. Some computer hardware devices, such as a touchscreen, can both send and receive data through the interface, while others such as a mouse or microphone may only provide an interface to send data to a given system.
Hardware interfaces exist in 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 with several electrical connections carrying parts of the data simultaneously, or serial where data are sent one bit at a time.
A software interface may refer to a wide 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 data streams, filters, and pipelines; and in object oriented programs, objects within an application may need to interact via methods.
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.Cite error: Closing
</ref> missing for
In object-oriented languages
In some object-oriented languages, especially those without full multiple inheritance, the term interface is used to define an abstract type that contains no data but defines behaviours as method signatures. A class having code and data for all the methods corresponding to that interface and declaring so is said to implement that interface. Furthermore, even in single-inheritance-languages, one can implement multiple interfaces, and hence can be of different types at the same time.
An interface is thus a type definition; anywhere an object can be exchanged (for example, in a function or method call) the type of the object to be exchanged can be defined in terms of one of its implemented interfaces or base-classes rather than specifying the specific class. This approach means that any class that implements that interface can be used. For example, a dummy implementation may be used to allow development to progress before the final implementation is available. In another case, a fake or mock implementation may be substituted during testing. Such stub implementations are replaced by real code later in the development process.
Usually a method defined in an interface contains no code and thus cannot itself be called; it must be implemented by non-abstract code to be run when it is invoked. An interface called "
Stack" might define two methods:
pop(). It can be implemented in different ways, for example,
GenericStack—the first being fast, working with a data structure of fixed size, and the second using a data structure that can be resized, but at the cost of somewhat lower speed.
Though interfaces can contain many methods they may contain only one or even none at all. For example, the Java language defines the interface
that has the single
method; various implementations are used for different purposes, including
. Marker interfaces like
contain no methods at all and serve to provide run-time information to generic processing using Reflection.
Programming to the interface
The use of interfaces allows for a programming style called programming to the interface. The idea behind this approach is to base programming logic on the interfaces of the objects used, rather than on internal implementation details. Programming to the interface reduces dependency on implementation specifics and makes code more reusable.
Pushing this idea to the extreme, inversion of control leaves the context to inject the code with the specific implementations of the interface that will be used to perform the work.
A user interface is a point of interaction between a computer and humans; it includes any number of modalities of interaction (such as graphics, sound, position, movement, etc.) where data is transferred between the user and the computer system.
- Abstraction inversion
- Application binary interface
- Application programming interface
- Business Interoperability Interface
- Computer bus
- Hard disk drive interface
- Implementation (computer science)
- Implementation inheritance
- Inheritance semantics
- Modular programming
- Software componentry
- Virtual inheritance
- Hookway, B. (2014). "Chapter 1: The Subject of the Interface". Interface. MIT Press. pp. 1–58. ISBN 9780262525503. https://books.google.com/books?id=BQM_AwAAQBAJ.
- "IEEE 100 - The Authoritative Dictionary Of IEEE Standards Terms". IEEE 100 - The Authoritative Dictionary Of IEEE Standards Terms. NYC, NY, USA: IEEE Press. 2000. pp. 574–575. ISBN 9780738126012.
- Blaauw, Gerritt A.; Brooks, Jr., Frederick P. (1997), "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. (2005), "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, https://archive.org/details/isbn_9781558606043/page/588
- Govindarajalu, B. (2008). "3.15 Peripheral Interfaces and Controllers - OG". IBM PC And Clones: Hardware, Troubleshooting And Maintenance. Tata McGraw-Hill Publishing Co. Ltd. pp. 142–144. ISBN 9780070483118. https://books.google.com/books?id=Hyl8SA1eHzIC&pg=PA142. Retrieved 15 June 2018.
- Buyya, R. (2013). Mastering Cloud Computing. Tata McGraw-Hill Education. p. 2.13. ISBN 9781259029950. https://books.google.com/books?id=VSDZAgAAQBAJ&pg=SA2-PA13.
- Poo, D.; Kiong, D.; Ashok, S. (2008). "Chapter 2: Object, Class, Message and Method". Object-Oriented Programming and Java. Springer-Verlag. pp. 7–15. ISBN 9781846289637. https://archive.org/details/springer_10.1007-978-1-84628-963-7.
- "What Is an Interface". The Java Tutorials. Oracle. Archived from the original on 2012-04-12. https://web.archive.org/web/20120412093619/http://docs.oracle.com/javase/tutorial/java/concepts/interface.html. Retrieved 2012-05-01.
- "Interfaces". The Java Tutorials. Oracle. Archived from the original on 2012-05-26. https://web.archive.org/web/20120526080117/http://docs.oracle.com/javase/tutorial/java/IandI/createinterface.html. Retrieved 2012-05-01.
- "Performance improvement techniques in Serialization". http://www.precisejava.com/: Precise Java. Archived from the original on 2011-08-24. https://web.archive.org/web/20110824150046/http://www.precisejava.com/javaperf/j2se/Serialization.htm. Retrieved 2011-08-04. "We will talk initially about Serializable interface. This is a marker interface and does not have any methods."
- Gamma; Helm; Johnson; Vlissides (1995). Design Patterns: Elements of Reusable Object-Oriented Software. Addison Wesley. pp. 17–18. https://archive.org/details/designpatternsel00gamm.
Original source: https://en.wikipedia.org/wiki/ Interface (computing). Read more