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. This may result in implementing lower-level features in terms of higher-level ones, thus the term 'abstraction inversion'. 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 their implementation with complex mechanical details. Many users attempt to solve the same problem, increasing the risk of error.
Examples 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. Applesoft BASIC and Lua (when configured for desktop computers) have a floating-point as the base numeric type. While Applesoft did implement integer arithmetic, it was implemented on top of floating-point arithmetic, and neither had any bitwise operators (Lua added support in Lua 5.2). 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.
See also Leaky abstraction Abstraction (computer science) Encapsulation (computer programming) Cargo cult programming Impedance mismatch
References
External links Abstraction Inversion at Portland Pattern Repository – extensive discussion, much of it taking "abstraction inversion" in the sense of "concealed complexity"