Programming abstraction (source code)

= Programming abstraction

<Programming abstraction> exposes a useful interface while suppressing details that clients need not depend on. A procedure abstracts a computation, an <abstract data type> abstracts a representation and its operations, and a <software module> organizes a boundary between cooperating components. The contract must state the behavior on which callers may rely.

For example, a <stack> interface can offer push, pop and an empty test. An <array> implementation and a linked-list implementation can satisfy that same interface, although their allocation and cost behavior differ. A caller that inspects private <array> indices has crossed the abstraction boundary. A <representation invariant> and operation specifications explain why the implementation realizes the interface. Abstraction therefore supports local reasoning and replacement, while resource guarantees still need to be part of the contract when clients depend on them.