System Design · Low-Level Design · Topic 2 of 3
Design Patterns
4 questions.
Your progress0%
- 1st Visit
- 0/4
- 2nd Visit
- 0/4
- Revise
- 0/4
Overview
Design patterns are reusable solutions to recurring object-oriented design problems, catalogued by the Gang of Four into creational, structural and behavioural groups. Interviewers rarely want all twenty-three; they ask about the few that appear constantly in real code and in low-level design problems. This topic covers Singleton, Factory, Observer and Strategy: the problem each solves, how it is structured, and where it fits. Signals in a design problem include a single shared resource (Singleton), object creation that depends on an input type (Factory), many components reacting to one event (Observer), and interchangeable algorithms such as pricing or payment rules (Strategy). Name a pattern only when it genuinely simplifies the design.
Questions
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | What is the Singleton pattern, and what are its drawbacks? | Concept | Easy | Read the answer to What is the Singleton pattern, and what are its drawbacks? | |||
| 2 | What is the Factory pattern, and when would you use it? | Concept | Medium | Read the answer to What is the Factory pattern, and when would you use it? | |||
| 3 | How does the Observer pattern work, and where is it used? | Concept | Medium | Read the answer to How does the Observer pattern work, and where is it used? | |||
| 4 | What is the Strategy pattern, and how does it differ from the State pattern? | Concept | Medium | Read the answer to What is the Strategy pattern, and how does it differ from the State pattern? |