Interview Q&A · questions with model answers

Design Patterns Interview Questions

Part of the study plan for: Backend Engineer · Tech Lead

Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.

  1. Most asked How do you implement a Singleton, and why is it often considered an anti-pattern?

    A Singleton has a private constructor and a static accessor that creates the single instance on first use and returns it afterwards. It's criticised because its global access hides dependencies,…

  2. Most asked How would you implement undo/redo with the Command pattern?

    Make each action an object with execute() and undo() that stores what it needs to reverse itself. An invoker runs commands and pushes them on a history stack; undo pops and calls undo() (moving the…

  3. How do you apply the Open/Closed Principle?

    Find the part that varies (payment methods, discount rules, export formats), put an abstraction there (an interface, a function type or a plugin list), and add new behaviour as new implementations…

  4. How do you safely refactor existing code toward a design pattern?

    Pin current behaviour with tests (characterisation tests if needed), then change structure in small steps: extract method, extract class or interface, replace conditional with polymorphism, move the…

  5. How would you refactor a god object?

    First pin its behaviour with characterisation tests. Then identify responsibilities that change for different reasons, extract each into a focused class, and inject those back into the original,…

  6. How would you explain to a junior developer how to choose the right design pattern?

    Start from the symptom, not the pattern: a growing if/else choosing algorithms suggests Strategy; a status switch in many methods suggests State; an incompatible interface suggests Adapter;…

Was this page helpful?

Report a mistake