Smart Abstraction Interview Questions

4 questions developers actually get asked about smart abstraction — with clear, practical answers you can use to prepare.

Q1. What is smart abstraction and why use it for AI calls?

Smart abstraction is a wrapper function that hides multiple provider options behind a single call. Instead of calling OpenAI directly in 50 places, you call generate_with_ai() everywhere, and that one function tries OpenAI first, falls back to Claude on failure, and returns a cached response if everything fails. The benefit is one place to update when providers change, and the app keeps running during outages.

Q2. How is smart abstraction different from the strategy pattern?

The strategy pattern lets a caller pick which algorithm runs. Smart abstraction picks for you, in priority order, with automatic fallback on failure. Strategy is about choice, smart abstraction is about resilience. They can be combined: your wrapper uses a configurable priority list (strategy) and walks down it on errors (smart abstraction).

Q3. What can go wrong if your wrapper has no timeouts?

A slow provider can hang the entire request. Without a timeout, your code waits indefinitely for OpenAI to respond and never reaches the fallback to Claude. Users see a spinner that never resolves. Always set a per-provider timeout so a slow primary moves on to a faster backup within a few seconds.

Q4. Why log which provider handled each request?

Without per-provider logs you have no idea when your primary started failing. Costs and latency look fine because the wrapper silently uses the backup, until the backup fails too and the whole feature breaks. Logging which provider succeeded turns a silent outage into a visible metric you can alert on.

Want the full concept, analogies, and AI prompts for smart abstraction?

Read the full Smart Abstraction block →