Abstraction principle (computer programming)

From Wiki @ Karl Jones dot com
Jump to: navigation, search

In software engineering and programming language theory, the abstraction principle (or the principle of abstraction) is a basic dictum that aims to reduce duplication of information in a program (usually with emphasis on code duplication) whenever practical by making use of abstractions provided by the programming language or software libraries.

Description

The principle is sometimes stated as a recommendation to the programmer, but sometimes stated as requirement of the programming language, assuming it is self-understood why abstractions are desirable to use.

The origins of the principle are uncertain; it has been reinvented a number of times, sometimes under a different name, with slight variations.

Don't Repeat Yourself (DRY)

When read as recommendation to the programmer, the abstraction principle can be generalized as the "Don't Repeat Yourself" (DRY) principle, which recommends avoiding the duplication of information in general, and also avoiding the duplication of human effort involved in the software development process.

Quotations

Benjamin C. Pierce, as a recommendation to computer programmers:

Each significant piece of functionality in a program should be implemented in just one place in the source code. Where similar functions are carried out by distinct pieces of code, it is generally beneficial to combine them into one by abstracting out the varying parts.

David A. Schmidt, on abstraction as a requirement in typed programming languages:

The phrases of any semantically meaningful syntactic class may be named.

See also

External links