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 Why is composition often preferred over inheritance?

    Composition (an object holds other objects it delegates to) lets you combine behaviours freely and change them at runtime, without the class explosion and tight coupling of deep inheritance…

  2. Why is a service locator considered worse than dependency injection?

    A class that pulls dependencies from a global locator (container.get("mailer")) hides what it needs: you can't see its dependencies from its constructor, tests must configure global state, and…

Was this page helpful?

Report a mistake