Abstraction inversion
Encyclopedia
In computer programming
Computer programming
Computer programming is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs. This source code is written in one or more programming languages. The purpose of programming is to create a program that performs specific operations or exhibits a...

, abstraction inversion is an anti-pattern
Anti-pattern
In software engineering, an anti-pattern is a pattern that may be commonly used but is ineffective and/or counterproductive in practice.The term was coined in 1995 by Andrew Koenig,...

 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.

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
    Semaphore (programming)
    In computer science, a semaphore is a variable or abstract data type that provides a simple but useful abstraction for controlling access by multiple processes to a common resource in a parallel programming environment....

     on the more complex basis.
  • In Applesoft BASIC
    Applesoft BASIC
    Applesoft BASIC was a dialect of Microsoft BASIC supplied with the Apple II series of computers. It superseded Integer BASIC and was the BASIC in ROM in all Apple II series computers after the original Apple II model. It was also referred to as FP because of the command used to invoke it instead...

    , integer
    Integer
    The integers are formed by the natural numbers together with the negatives of the non-zero natural numbers .They are known as Positive and Negative Integers respectively...

     arithmetic was implemented on top of floating-point arithmetic
    Floating point
    In computing, floating point describes a method of representing real numbers in a way that can support a wide range of values. Numbers are, in general, represented approximately to a fixed number of significant digits and scaled using an exponent. The base for the scaling is normally 2, 10 or 16...

    , and there were no bitwise operators
    Bitwise operation
    A bitwise operation operates on one or more bit patterns or binary numerals at the level of their individual bits. This is used directly at the digital hardware level as well as in microcode, machine code and certain kinds of high level languages...

     and no support for blit
    Bit blit
    Bit BLIT is a computer graphics operation in which several bitmaps are combined into one using a raster operator....

    ting of raster graphics
    Raster graphics
    In computer graphics, a raster graphics image, or bitmap, is a data structure representing a generally rectangular grid of pixels, or points of color, viewable via a monitor, paper, or other display medium...

     (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.
  • Like Applesoft BASIC, Lua has a floating-point type as its sole numeric type when configured for desktop computers. and no bitwise operators.
  • A body of opinion holds the microkernel
    Microkernel
    In computer science, a microkernel is the near-minimum amount of software that can provide the mechanisms needed to implement an operating system . These mechanisms include low-level address space management, thread management, and inter-process communication...

     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.
  • Creating an object to represent a function is cumbersome in object-oriented languages such as Java
    Java (programming language)
    Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

     and C++
    C++
    C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

    , in which functions are not first-class object
    First-class object
    In programming language design, a first-class citizen , in the context of a particular programming language, is an entity that can be constructed at run-time, passed as a parameter, returned from a subroutine, or assigned into a variable...

    s. 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 Functors in the STL.
  • The Scheme programming language exhibits abstraction inversion with respect to imperative vs. tail recursive constructs in the presence of continuations.
  • 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.


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.

External links

  • Abstraction Inversion at Portland Pattern Repository - extensive discussion, much of it taking "abstraction inversion" in the sense of "concealed complexity"
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK