Abstraction inversion

Abstraction inversion

In computer programming, abstraction inversion is an anti-pattern arising when users of a construct need functions implemented within it but not exposed by its interface. The result is that the users re-implement the required functions in terms of the interface, which in its turn uses the internal implementation of the same functions.

The term "abstraction inversion" is sometimes misunderstood as referring to complex (or concrete) constructs with simple (or abstract) interfaces, which are normal and desirable.

Possible ill-effects are:
* The user of such a re-implemented function may seriously underestimate its running-costs.
* The user of the construct is forced to obscure his implementation with complex mechanical details.
* Many users attempt to solve the same problem, increasing the risk of error.

Abstraction inversion in practice

Ways to avoid this anti-pattern include:: For designers of lower-level software::* If your system offers formally equivalent functions, choose carefully which to implement in terms of the other.:* Do not force unnecessarily weak constructs on your users.: For implementers of higher-level software::* Choose your infrastructure carefully.

Examples

Alleged examples from professional programming circles include:
* In Ada, choice of the "rendezvous" construct as a synchronisation primitive forced programmers to implement simpler constructs such as semaphores on the more complex basis. [http://www.pipeline.com/~hbaker1/CritLisp.html#fn2 Critique of DIN Kernel Lisp Definition Version 1.2, footnote 2] - says (without references) that the term derives from critiques of the Ada "rendezvous", appears to be one of the earliest uses.]
* In Applesoft BASIC, integer arithmetic was implemented on top of floating-point arithmetic, and there were no bitwise operators and no support for blitting of raster graphics (even though the language supported vector graphics on the Apple II's raster hardware). This caused games and other programs written in BASIC to run more slowly.
* A body of opinion holds the microkernel design to be an abstraction inversion (see the links). It is interesting that microkernels are also alleged to commit the design error of oversimplifying the components so as to overcomplicate their relationships. [http://plan9.escet.urjc.es/usr/nemo/export/hotos-didos/node2.html Distribute those centralized microkernels] in [http://plan9.escet.urjc.es/usr/nemo/export/hotos-didos/hotos-didos.html The Network Hardware Is the Operating System] (Francisco J. Ballesteros and Luis L. Fernandez, 1997) suggests that "ill-designed" microkernels offer simple abstractions with heavyweight implementations, and that this may be called an "abstraction inversion".] The article ' [http://tunes.org/wiki/Microkernel Microkernel] ' at tunes.org gives many of the arguments against microkernels and suggests that it is an abstraction inversion to implement a modular high-level design using a low-level module manager.]
* Creating an object to represent a function is cumbersome in object-oriented languages such as Java and C++, in which functions are not first-class objects. In Java, a function has to be implemented by a method of an interface, sometimes in a class with no other justification for its existence. An example from Java is the method [http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runnable.html#run() Runnable.run()] , required by the method [http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#run() Thread.run()] . In C++ it is possible to make an object 'callable' by overloading the () operator, but it is still often necessary to implement a new class, such as the [http://www.sgi.com/tech/stl/functors.html Functors in the STL] .
* The Scheme programming language exhibits abstraction inversion w.r.t. imperative vs. tail recursive constructs in the presence of continuations.http://lists.tunes.org/archives/tunes/1999-August.txt]
* Tom Lord has suggested that Subversion version control system pays for the abstraction inversion of implementing a write-only database on a read/write database with poor performance. [http://sourcefrog.net/weblog/software/vc/subversion/lord-on-svn.html sourcefrog : Tom Lord on Subversion ] ]

Examples that are common outside professional programming circles include:

* Using spreadsheet lookup functions to replicate the functionality of a database
* Using variant data types as loop counters in Microsoft Visual Basic where an integer type is also available.

References

External links

* [http://c2.com/cgi/wiki?AbstractionInversion Abstraction Inversion] at Portland Pattern Repository


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Abstraction (computer science) — In computer science, abstraction is the process by which data and programs are defined with a representation similar to its pictorial meaning as rooted in the more complex realm of human life and language with their higher need of summarization… …   Wikipedia

  • Inversión de abstracción — En computación, el antipatrón de diseño inversión de abstracción (en inglés abstraction inversion) ocurre cuando un programador construye una interfaz que no expone las funcionalidades requeridas por los usuarios, aunque estas sean efectivamente… …   Wikipedia Español

  • Inversión de abstracción — En computación, el antipatrón de diseño inversión de abstracción (en inglés abstraction inversion) ocurre cuando un programador crea una construcción simple que esconde una construcción muy complicada. La forma correcta debería ser al contrario:… …   Enciclopedia Universal

  • Inversion of control — In software engineering, Inversion of Control (IoC) is an abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to procedural programming. In traditional… …   Wikipedia

  • Leaky abstraction — A leaky abstraction is a notion applied to implementations of an abstraction. This notion, attributed to software commentator Joel Spolsky, indicates that specific implementation details manifest themselves in some obstructive or counter… …   Wikipedia

  • Dependency inversion principle — In object oriented programming, the dependency inversion principle refers to a specific form of decoupling where conventional dependency relationships established from high level, policy setting modules to low level, dependency modules are… …   Wikipedia

  • Anti-pattern — For the book, see AntiPatterns. In software engineering, an anti pattern (or antipattern) is a pattern that may be commonly used but is ineffective and/or counterproductive in practice.[1][2] The term was coined in 1995 by Andrew Koenig,[3]… …   Wikipedia

  • Interface (computer science) — Interface generally refers to an abstraction that an entity provides of itself to the outside. This separates the methods of external communication from internal operation, and allows it to be internally modified without affecting the way outside …   Wikipedia

  • Antipatrón de diseño — Saltar a navegación, búsqueda Un antipatrón de diseño es un patrón de diseño que invariablemente conduce a una mala solución para un problema. Al documentarse los antipatrones, además de los patrones de diseño, se dan argumentos a los diseñadores …   Wikipedia Español

  • Interface (computing) — For other uses, see Interface. In the field of computer science, an interface is a tool and concept that refers to a point of interaction between components, and is applicable at the level of both hardware and software. This allows a component,… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”