Interview Q&A / Object-Oriented Programming

AdvancedQuick answer1 min readUpdated 3 Oct 2026

What is a leaky abstraction?

SHORT ANSWER

A leaky abstraction promises to hide a detail but fails in some situations, so the user has to understand the hidden layer anyway. The simple view stops being enough.

Explain it simply

A railway app shows "Seat confirmed" and hides the network, the servers and the queue. That works until the app freezes at 10 AM when Tatkal opens. Now you must think about load and retries, the things the app was meant to hide. That is a leak.

Every abstraction leaks somewhere. The aim is to leak rarely and to document where.

Example

python
# A list "hides" storage, but cost leaks through.
items = list(range(100000))

def has(x):
    return x in items          # looks like one line, but scans up to 100000 items

lookup = set(items)
def has_fast(x):
    return x in lookup         # same syntax, very different cost

An ORM is another classic case: user.orders looks like a field, but each access can fire a database query, so a loop over users can run hundreds of queries.

What to say in the interview

"A leaky abstraction hides a detail until some case, usually performance, failure or concurrency, forces you to know it. I use abstractions for convenience but still learn the layer beneath, and I document the limits of my own abstractions."

Common mistakes

  • Thinking more abstraction is always better.

#abstraction#design#trade-offs

Related questions

Practise more Object-Oriented Programming questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Object-Oriented Programming quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.