World Library  
Flag as Inappropriate
Email this Article

Leaky abstraction

Article Id: WHEBN0006533945
Reproduction Date:

Title: Leaky abstraction  
Author: World Heritage Encyclopedia
Language: English
Subject: Abstraction, Reference desk/Archives/Computing/2014 July 27, Abstraction (computer science)
Collection: Abstraction
Publisher: World Heritage Encyclopedia

Leaky abstraction

In software development, a leaky abstraction is an implemented abstraction where details and limitations of the implementation leak through.


  • History 1
  • The Law of Leaky Abstractions 2
  • Effect on software development 3
  • Examples 4
  • See also 5
  • References 6


The term "leaky abstraction" was popularized in 2002 by Joel Spolsky.[1] An earlier 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.[2]

The Law of Leaky Abstractions

As coined by Spolsky, the Law of Leaky Abstractions states:

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.

Effect on software development

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:

  • The TCP/IP protocol stack is the combination of the TCP protocol, which tries to provide reliable delivery of information, running on top of the IP protocol, which provides only 'best-effort' service. When IP loses a packet TCP has to retransmit it, which takes additional time. Thus TCP provides the abstraction of a reliable connection, but the implementation details leak through in the form of potentially variable performance (throughput and latency both suffer when data has to be retransmitted).
  • Iterating over a large two-dimensional array can have radically different performance if done horizontally rather than vertically, depending on the order in which elements are stored in memory. One direction may vastly increase cache misses and page faults, both of which greatly delay access to memory.
  • The SQL language abstracts away the procedural steps for querying a database, allowing one to merely define what one wants. But certain SQL queries are thousands of times slower than other logically equivalent queries. On an even higher level of abstraction, ORM systems, which isolate object-oriented code from the implementation of object persistence using a relational database, still force the programmer to think in terms of databases, tables, and native SQL queries as soon as performance of ORM-generated queries becomes a concern.
  • Although network file systems like NFS and SMB let one treat files on remote machines as if they were local, the connection to the remote machine may slow down or break, and the file stops acting as if it was local.
  • The ASP.NET web programming platform abstracts away the difference between HTML code to handle clicking on a hyperlink () 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 fundamental limitations of the Web, processing event handlers in ASP.NET requires exchanging data with the server and reloading the form.

See also


  1. ^ Spolsky, Joel (2002). "The Law of Leaky Abstractions". Retrieved 2010-09-22.  - a blog post by Spolsky that asserts that all non-trivial abstractions are 'leaky' and therefore problematic.
  2. ^ Kiczales, Gregor (1992). "Towards a New Model of Abstraction in the Engineering of Software". Retrieved 2010-02-03.  - a paper by Gregor Kiczales that describes the problem of imperfect abstractions and suggests a programming model for coping with them.
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.