Abstraction inversion
   HOME

TheInfoList



OR:

In
computer programming Computer programming is the process of performing a particular computation (or more generally, accomplishing a specific computing result), usually by designing and building an executable computer program. Programming involves tasks such as anal ...
, abstraction inversion is an
anti-pattern An anti-pattern in software engineering, project management, and business processes is a common response to a recurring problem that is usually ineffective and risks being highly counterproductive. The term, coined in 1995 by computer programmer An ...
arising when users of a construct need functions implemented within it but not exposed by its
interface Interface or interfacing may refer to: Academic journals * ''Interface'' (journal), by the Electrochemical Society * '' Interface, Journal of Applied Linguistics'', now merged with ''ITL International Journal of Applied Linguistics'' * '' Int ...
. 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

Alleged examples from professional programming circles include: * In
Ada Ada may refer to: Places Africa * Ada Foah, a town in Ghana * Ada (Ghana parliament constituency) * Ada, Osun, a town in Nigeria Asia * Ada, Urmia, a village in West Azerbaijan Province, Iran * Ada, Karaman, a village in Karaman Province, ...
, choice of the ''rendezvous'' construct as a synchronisation primitive forced programmers to implement simpler constructs such as semaphores on the more complex basis.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 Applesoft BASIC is a dialect of Microsoft BASIC, developed by Marc McDonald and Ric Weiland, supplied with the Apple II series of computers. It supersedes Integer BASIC and is the BASIC in ROM in all Apple II series computers after the origina ...
,
integer An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the languag ...
arithmetic was implemented on top of floating-point arithmetic, and there were no
bitwise operators In computer programming, a bitwise operation operates on a bit string, a bit array or a binary numeral (considered as a bit string) at the level of its individual bits. It is a fast and simple action, basic to the higher-level arithmetic operat ...
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 slower. * Like Applesoft BASIC,
Lua Lua or LUA may refer to: Science and technology * Lua (programming language) * Latvia University of Agriculture * Last universal ancestor, in evolution Ethnicity and language * Lua people, of Laos * Lawa people, of Thailand sometimes referred t ...
has a floating-point type as its sole numeric type when configured for desktop computers, and it had no bitwise operators prior to Lua 5.2. * Creating an object to represent a function is cumbersome in
object-oriented Object-oriented programming (OOP) is a programming paradigm based on the concept of " objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of p ...
languages such as
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mos ...
and
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
(especially prior to C++11 and Java 8), in which functions are not
first-class object In programming language design, a first-class citizen (also type, object, entity, or value) in a given programming language is an entity which supports all the operations generally available to other entities. These operations typically include ...
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
'. (
C++11 C++11 is a version of the ISO/ IEC 14882 standard for the C++ programming language. C++11 replaced the prior version of the C++ standard, called C++03, and was later replaced by C++14. The name follows the tradition of naming language versions b ...
's lambda function makes it much easier to create an object representing a function.) * 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.sourcefrog : Tom Lord on Subversion
/ref> * Using stored procedures to manipulate data in a relational database, without granting programmers right to deploy such procedures, leads to reimplementing queries outside the database. For example, large datasets (in extreme cases - whole tables) are fetched and actual filtering takes place in application code. Alternatively, thousands of rows are updated (inserted or even fetched) one by one instead of running a multiple row query. * Microsoft's
WinUI 3 Windows UI Library (WinUI codenamed "Jupiter", and also known as UWP XAML and WinRT XAML) is a user interface API that is part of the Windows Runtime programming model that forms the backbone of Universal Windows Platform apps (formerly known a ...
systematically replaces the title bar of the windows it creates with a custom one that ignores the end-user's color settings, always appearing gray instead. Applying the end-user's chosen color to the title bar requires using further customization code on Windows 11, and completely replacing the custom title bar with another custom one on Windows 10.https://learn.microsoft.com/en-us/windows/apps/develop/title-bar 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.


See also

*
Leaky abstraction In software development, a leaky abstraction is an abstraction that leaks details that it is supposed to abstract away. As coined by Joel Spolsky, the Law of Leaky Abstractions states: This statement highlights a particularly problematic cause ...


References

{{reflist


External links

* Abstraction Inversion at Portland Pattern Repository - extensive discussion, much of it taking "abstraction inversion" in the sense of "concealed complexity" Anti-patterns