liveBook · Manning

Leaky abstraction

As explained in Functional Design and Architecture: Examples in Haskell

A leaky abstraction is an abstraction whose exposed behavior or interface reveals details of its underlying implementation.

A leaky abstraction reveals implementation details instead of hiding them. It may solve part of a problem, yet make the broader design harder to change. Rather than removing complexity, it adds complexity that clients must understand and work around. section 2.1.2 section 2.3

Leaks are especially damaging during refactoring. Implementation concerns seep into client code, then spread across a project, so a change intended to improve the whole design meets dependencies on the old details. section 2.1.2 section 2.3

Layering abstractions until they leak

C++ templates illustrate the risk: a developer can build an elaborate abstraction to solve a problem, but awkward syntax and fragile layers create a “house of cards.” Adding abstractions over abstractions becomes over-engineering when the resulting structure exposes its own traps instead of presenting a stable design. section 2.1.2

Functional idioms, higher-order functions, and mathematically inspired concepts can support powerful abstractions, but none are automatically leak-proof in practical software engineering. Judge an abstraction by whether it reduces complexity and preserves freedom to change the design. section 2.1.2 section 2.3

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Defines leaks and explains their effects on client code, complexity, and refactoring without prescribing detection steps or repairs.
Examples
Uses fragile C++ template layers as the concrete example of abstractions over abstractions that can leak.
What it assumes
Teaches the term from zero while situating it among functions, lambdas, and higher-order functions.
What you can do after
Evaluate/understand whether an abstraction hides implementation details or increases complexity and resists refactoring.
How it connects
Connects abstraction design with refactoring, functional programming, higher-order functions, software architecture, and embedded domain-specific languages.

Also explained in

Compare how 3 books explain leaky abstraction →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Design and Architecture: Examples in Haskell. The section links point to the parts of the book it draws on.