Design Patterns Interview Questions: Judgment Over Recall

Answer design patterns interview questions with a four-beat script — problem, pattern, cost, alternative — backed by a worked Python refactor and a skip-signal table.

By AI Interview AssistantPublished 11 min read

A software engineer at a whiteboard sketching a class diagram of boxes and arrows while explaining a design choice to a colleague

A desk with a laptop showing abstract code, beside a notebook sketch of two interlocking boxes, a pencil and a coffee

Treat each design patterns interview question as a design judgment, not a definition test. Name the problem the pattern solves, say what it costs, and give one place you would use it and one place you would not. If you can explain why a simpler solution fails first, the person across the table sees engineering judgment rather than memorized trivia.

What a design patterns interview question is really checking

A pattern question is a design question wearing a vocabulary. The interviewer wants to know whether you can spot a recurring design problem, weigh the cost of the fix, and stop when the fix is more expensive than the problem.

A strong answer shows three things:

  • The problem before the pattern. What in the code is actually hurting?
  • The trade-off the pattern buys. What does the indirection purchase, and what does it charge?
  • A reason to reject it. Where would you not use it, and why?

Reciting the Gang of Four definition first signals memorization. It also hands the interviewer an easy follow-up — "so when would you not use it?" — that a definition-only answer cannot survive. Leading with the problem keeps the conversation on ground you have prepared.

The four-beat answer: problem, pattern, cost, alternative

Use the same four beats for every pattern question, in this order:

  1. Problem. Describe the concrete situation in one sentence: "a payment flow that must support new providers without editing the checkout class."
  2. Pattern. Name it and say what it isolates: "Strategy puts the varying algorithm behind an interface, so checkout depends on the interface, not the provider."
  3. Cost. State what the pattern adds: an extra interface, one more level of indirection, a stack trace that no longer points at a single method.
  4. Alternative. Name the simpler option you rejected and the condition that would make you keep it: "a switch statement until the number of providers grows past three, or until they start changing independently."

Here is the whole thing spoken, at roughly 60 seconds:

"Say we have a checkout that charges cards through a few providers, and a fourth is coming next quarter. The thing that changes is the charging algorithm, so I want to isolate that. I'd use Strategy: a PaymentProvider interface with a charge method, and one class per provider. Checkout picks a provider and calls charge. The cost is one interface, one class per provider, and a registry to wire them up — and when a charge fails, the trace goes through the interface, so it's a little harder to read. I'd skip it if there were two stable providers and no plan to add more; a switch would be clearer. Once the branch count is growing or providers change on their own schedule, Strategy earns the indirection."

Notice what the answer does: it commits to a choice, names the cost without being asked, and gives the interviewer a reason to trust the choice. For more on structuring answers around trade-offs, see object-oriented design answers and trade-offs.

Worked example: Strategy vs a switch statement

Take a checkout class that charges cards through three providers and will add a fourth next quarter. The first version switches on provider name:

class Checkout:
    def __init__(self, provider_name):
        self.provider_name = provider_name

    def charge(self, amount):
        if self.provider_name == "card":
            return f"card charged {amount}"
        elif self.provider_name == "wallet":
            return f"wallet charged {amount}"
        elif self.provider_name == "bank":
            return f"bank charged {amount}"
        raise ValueError(f"unknown provider: {self.provider_name}")

Now the Strategy version. A protocol defines the contract; each provider is its own class; checkout holds a provider object:

from typing import Protocol

class PaymentProvider(Protocol):
    def charge(self, amount: int) -> str: ...

class CardProvider:
    def charge(self, amount: int) -> str:
        return f"card charged {amount}"

class WalletProvider:
    def charge(self, amount: int) -> str:
        return f"wallet charged {amount}"

class BankProvider:
    def charge(self, amount: int) -> str:
        return f"bank charged {amount}"

class Checkout:
    def __init__(self, provider: PaymentProvider):
        self.provider = provider

    def charge(self, amount: int) -> str:
        return self.provider.charge(amount)

Trace one call, Checkout(CardProvider()).charge(100). The constructor stores the CardProvider instance. charge(100) calls CardProvider.charge(100), which returns "card charged 100". Swap in WalletProvider() and the same call returns "wallet charged 100". Checkout's code does not change between the two.

The cost is real. You now have one file per provider, a registry somewhere to map a name to an instance, and a stack trace that shows Checkout.charge calling CardProvider.charge instead of pointing at one branch inside a single method. Adding a fifth provider means adding a class and a registry entry — you touch the registry, not checkout.

The decision rule: introduce Strategy when the branch count is growing or providers change independently; keep the switch when it is two stable cases that nobody is asking to extend.

Patterns that earn their keep and patterns that don't

Some patterns solve real problems often enough that they pay for themselves quickly. Others get applied by habit. Here is the comparison that matters when you are choosing:

PatternProblem it solvesCost it addsSignal to skip it
StrategySwapping algorithms without editing the callerAn interface, one class per algorithm, wiringTwo stable cases, no planned variation
ObserverMany listeners reacting to one eventIndirection in the call chain, harder orderingOne listener, or a direct call would do
AdapterA third-party interface you cannot changeA translation layer to maintainYou control both sides already
FactoryConstruction with real branchingA factory class or function per familyConstruction is a plain constructor call
DecoratorAdding behaviour around an objectWrapping order matters, traces get deeperOne small behaviour, easy to put in the class

Three patterns are over-applied more than most:

  • Singleton, which is usually a global variable in disguise. The simpler alternative is passing the dependency in where it is needed, which also makes tests easier to isolate.
  • Abstract Factory for a single family that will never vary. The simpler alternative is a plain factory function or a constructor call.
  • Deep Decorator chains stacked three deep for a one-line behaviour. The simpler alternative is putting that line in the class, or in one wrapper rather than three.

Saying "I would not use a pattern here" is fine when you do it in three parts: name the pattern, name the cost, name the simpler option. That shows you know the pattern and chose against it, which is a different signal from not knowing it at all.

Answering 'which pattern would you use here?' live

For live questions, restate the constraint first: "the thing that changes is X, so I want to isolate X." That sentence buys you a moment and shows the interviewer what you are optimizing for.

Then offer two candidates and pick one with a reason. Naming a single pattern as if it were the only answer sounds like recall; naming two and choosing sounds like design. "Strategy or a simple function map — I'd take Strategy here because the providers will grow and each has its own error handling."

If you cannot recall a pattern's name, describe the shape and move on:

"I don't remember the name for this one, but the shape is an interface with one method per algorithm, chosen at runtime. That's what I'd write here."

That answer is honest and still useful. Interviewers care more about the shape than the label. For more on keeping answers moving under pressure, see software engineer live answer frameworks.

Follow-ups that separate judgment from recall

Expect the conversation to go one level deeper. Three follow-ups come up often, and each has a shape of answer:

  • "What breaks if we add a fifth provider tomorrow?" Answer with the files: you would add one provider class and one registry entry, and you would not touch checkout. Naming both the file you touch and the file you leave alone shows you understand the boundary.
  • "Why not just use inheritance?" Answer with the combinatorial explosion: one subclass per provider-and-behaviour combination multiplies quickly. Composition lets you vary the provider without multiplying classes.
  • "When would you remove this pattern?" Answer with the signal: one implementation, no planned variation, and tests getting harder to write because of the indirection. That is the point where the pattern costs more than it saves.

If the question moves into a broader system, the same judgment applies to boundaries and contracts; API design system design narration covers how to talk through those choices out loud.

The one rule to carry into the room

Every pattern answer ends with a cost and a rejected alternative. If you cannot name either, you do not yet own the pattern — you have only memorized it. Practise the four beats spoken aloud on three patterns you actually use in your work, not all 23. Three owned patterns will carry you through more design patterns interview questions than a shallow pass over the full catalogue, because the exercise is testing whether you can reason about a design, and reasoning is what the four beats demonstrate.

Frequently asked questions

Do I need to memorize all 23 Gang of Four patterns for an interview?

No. Most interviews probe a handful of patterns you have actually used, and depth beats breadth. Learn five or six well enough to state the problem, the cost and a place you would skip them, and be ready to describe the shape of anything else you half-remember. A candidate who owns three patterns usually sounds stronger than one who recites twenty.

What if the interviewer uses a pattern name I've never heard?

Ask what problem it solves in their context, then reason from the problem. You can say you do not know that name and describe the shape you would write instead. Interviewers generally accept an honest gap followed by clear reasoning; what they penalize is bluffing a definition you cannot defend when the follow-up arrives.

Is it bad to say 'I wouldn't use a pattern here'?

It is good when you give the reason. Name the pattern, name the cost it would add, and name the simpler option you would keep. That sequence shows you know the pattern and judged it unnecessary. The answer only lands badly if you reject the pattern without showing you understand what it would have bought.

How do design patterns come up in a system design interview rather than a coding one?

They appear as boundary choices: an Adapter at a third-party integration, Observer for event fan-out, Strategy for pluggable algorithms such as routing or pricing. The same rule applies — say what varies, what the pattern isolates, and what it costs in operational terms. The discussion is about the trade-off, not the label.

Can I use AI to practise pattern questions without it just feeding me definitions?

Yes, if you use it to rehearse the four beats rather than to collect definitions. Ask for a scenario, answer aloud with problem, pattern, cost and alternative, then check whether your reasoning holds. AI guidance can be wrong or generic, so verify the code and the trade-offs yourself and answer in your own words.

Practising pattern answers? See how AI Interview assistant works.

  • Design patterns interview questions
  • Software design patterns interview
  • Software engineer interview
  • Object oriented design interview
Wooden building blocks arranged in a parent-and-child hierarchy beside a laptop and a sketch of boxes

10 min read

Object-Oriented Design Interview Questions: Answer, Then Defend

A repeatable way to answer object-oriented design interview questions: define the concept in one sentence, name the trade-off in the next, then back it with a concrete example.

  • Object oriented design interview questions
  • Object oriented design interview answers
Two engineers pair-programming at one laptop, one typing while the other points at the code on screen

14 min read

Software Engineer Interview Questions: Live Answer Frameworks

A practical guide to software engineer interview questions, with real-time frameworks for behavioural, technical and mixed answers you can adapt while speaking.

  • Software engineer interview questions
  • Software engineer interview answers
A test bench with a laptop, phone and tablet side by side running app screens, a checklist and a magnifying glass

12 min read

Software Testing Interview Questions: Choose and Defend

Answer software testing interview questions by naming what you would test, what you would skip and why. Includes a 60-second login example and a practice routine.

  • Software testing interview questions
  • Software testing interview answers