An “abstract interface” is a higher-order abstraction that can represent one or more concrete implementations. An abstract interface defines the required minimum contract that all suitable implementations must satisfy: function signatures, preconditions, postconditions, and behavioral guarantees. What is revealed is the contract callers can rely on; what is hidden are internal state, algorithms, and platform dependencies. Note that the interface captures what all valid implementations must provide, not the union of every possible feature.
Abstract interfaces can take many forms, all of which are mechanisms for expressing the same thing: a contract that callers can rely on and implementations must satisfy.
- a straightforward header-defined interface
- a collection of function pointers
- an abstract base class
- Rust traits
- C++ concepts or templates
Abstract interfaces are used to improve the changeability of software. Programs are written against the interface, keeping details about the underlying implementation secret. The fundamental goal is to be able to swap different implementations without needing to change components that interact with the interface.
Courses
Blog Posts
- How Our Approach to Abstract Interfaces Has Changed Over the Years
- Virtual Devices in Embedded Systems Software
- Practical Decoupling Techniques Applied to a C-based Radio Driver
Papers
- For information on designing abstract interfaces for device drivers, see the paper “A Procedure for Designing Abstract Interfaces for Device Interface Modules” by David Parnas et al. . This paper provides a procedure for creating abstract interfaces, discusses common design challenges with creating abstract interfaces for device drivers, and provides examples from a real-world avionics program.
- Abstract Interface Specifications for the A-7E Device Interface Module by David Parnas et al.
- Use of Abstract Interfaces in the Development of Software for Embedded Computer Systems by David Parnas
- Paper: Towards a New Model of Abstraction in Software Engineering by Gregor Kiczales
Selected Quotes
- Abstract Interface Specifications for the A-7E Device Interface Module by Parker, Heninger, and Parnas
Interface: The interface between two programs consists of the set of assumptions that each programmer needs to make about the other program in order to demonstrate the correctness of his own program. For convenience, we use the phrase “assumptions made by program A about program B,” to mean the properties of B that must be true in order for A to work properly. These assumptions are not limited to the calling sequences and parameter formats traditionally found in interface documents; they include additional information such as the meaning and limits of information exchanged, restrictions on the order of events, and expected behavior when undesired events (ref (7)) occur. There is an analogous definition of the interface between a program and a device.
Abstract interface: An abstract interface is an abstraction that represents more than one interface; it consists of the assumptions that are included in all of the interfaces that it represents. An abstract interface for a given type of device reveals some, but not all, properties of the actual device: it describes the common aspects of devices of that type, omitting the aspects that distinguish them from each other.
« Back to Glossary Index
