In software development, a leaky abstraction is an abstraction that leaks details that it is supposed to abstract away.[1]
As coined by Joel Spolsky, the Law of Leaky Abstractions states:[2]
“ | All non-trivial abstractions, to some degree, are leaky. | ” |
This statement highlights a particularly problematic cause of software defects: the reliance of the software developer on an abstraction's infallibility.
Spolsky's article gives examples of an abstraction that works most of the time, but where a detail of the underlying complexity cannot be ignored, thus leaking complexity out of the abstraction back into the software that uses the abstraction.
The term "leaky abstraction" was popularized in 2002 by Joel Spolsky.[2][3] A 1992 paper by Kiczales describes some of the issues with imperfect abstractions and presents a potential solution to the problem by allowing for the customization of the abstraction itself.[4]
As systems become more complex, software developers must rely upon more abstractions. Each abstraction tries to hide complexity, letting a developer write software that "handles" the many variations of modern computing.
However, this law claims that developers of reliable software must learn the abstraction's underlying details anyway.
Spolsky's article cites many examples of leaky abstractions that create problems for software development:
<a>
) and code to handle clicking on a button. However, ASP.NET needs to hide the fact that in HTML there is no way to submit a form from a hyperlink. It does this by generating a few lines of JavaScript and attaching an onclick handler to the hyperlink. However, if the end user has JavaScript disabled, the ASP.NET application malfunctions. Furthermore, one cannot naively think of event handlers in ASP.NET in the same way as in a desktop GUI framework such as Windows Forms; due to the asynchronous nature of the Web, processing event handlers in ASP.NET requires exchanging data with the server and reloading the form.In 2020, Massachusetts Institute of Technology computing science teaching staff Anish, Jose, and Jon argued that the command line interface for git is a leaky abstraction, in which the underlying "beautiful design" of the git data model needs to be understood for effective usage of git.[5]
Original source: https://en.wikipedia.org/wiki/Leaky abstraction.
Read more |