Content deleted Content added
m Dating maintenance tags: {{Citation Needed}} |
Citation bot (talk | contribs) Alter: url. URLs might have been anonymized. | Use this bot. Report bugs. | #UCB_CommandLine |
||
(12 intermediate revisions by 9 users not shown) | |||
Line 1:
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 [[abstraction (computer science)|abstraction]]s provided by the programming language or [[software libraries]]
When read as
== The principle ==
Line 11:
== History and variations ==
* Alfred John Cole, Ronald Morrison (1982) ''An introduction to programming with S-algol'': "[Abstraction] when applied to language design is to define all the semantically meaningful syntactic categories in the language and allow an abstraction over them".<ref>Alfred John Cole, Ronald Morrison, ''An introduction to programming with S-algol'', CUP Archive, 1982, {{ISBN|0-521-25001-3}}, p. 150</ref>
Line 17:
* Jon Pearce (1998) ''Programming and Meta-Programming in Scheme'': "Structure and function should be independent".<ref>Jon Pearce, ''Programming and meta-programming in scheme'', Birkhäuser, 1998, {{ISBN|0-387-98320-1}}, p. 40</ref>
The principle plays a central role in [[Design pattern (computer science)|design patterns]] in [[object-oriented programming]], although most writings on that topic do not give a name to the principle. The [[Design Patterns (book)|
In this century, the principle has been reinvented in [[extreme programming]] under the slogan "Once and Only Once". The definition of this principle was rather succinct in its first appearance: "no duplicate code".<ref>Kent Beck, ''Extreme programming explained: embrace change'', 2nd edition, Addison-Wesley, 2000, {{ISBN|0-201-61641-6}}, p. 61</ref> It has later been elaborated as applicable to other issues in software development: "Automate every process that's worth automating. If you find yourself performing a task many times, script it."<ref>Chromatic, ''Extreme programming pocket guide'', O'Reilly, 2003, {{ISBN|0-596-00485-0}}</ref>
Line 24:
The abstraction principle is often stated in the context of some mechanism intended to facilitate abstraction. The basic mechanism of control abstraction is a function or [[subroutine]]. Data abstractions include various forms of [[type polymorphism]]. More elaborate mechanisms that may combine data and control abstractions include: [[abstract data type]]s, including [[Class (computer science)|classes]], [[Polymorphism_(computer_science)#Polytypism|polytypism]] etc. The quest for richer abstractions that allow less duplication in complex scenarios is one of the driving forces in programming language research and design.
Inexperienced programmers may be tempted to introduce too much abstraction in their program—abstraction that won't be used more than once. {{Citation needed|date=March 2013}} A complementary principle that
Since code is usually subject to revisions, following the abstraction principle may entail [[refactoring]]
== Generalizations ==
"[[Don't repeat yourself]]", or the "DRY principle", is a generalization developed in the context of [[multi-tier architecture]]s, where related code is by necessity duplicated to some extent across tiers, usually in different languages. In practical terms, the recommendation here is to rely on automated tools, like [[Automatic programming|code
== Hardware programming interfaces ==
|