Design Patterns interview question · Most asked
What are the three categories of Gang of Four design patterns?
Summary
Creational patterns deal with object creation (Factory Method, Abstract Factory, Builder, Prototype, Singleton), structural patterns with composing objects (Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy), and behavioral patterns with how objects communicate and share responsibilities (Chain of Responsibility, Command, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor, Interpreter).
Longer Answer
The 23 classic patterns split 5 / 7 / 11 across the three families. A quick way to remember them: creational answers "how do I create objects flexibly?", structural answers "how do I fit objects together?", and behavioral answers "how do objects divide work and talk to each other?".
Modern codebases add patterns beyond the original 23, such as dependency injection, repository, middleware and pub/sub, which build on the same ideas.
Key Points
- Creational: 5 patterns about creating objects.
- Structural: 7 patterns about composing objects.
- Behavioral: 11 patterns about communication and responsibility.
Deep dive: Design Patterns, Explained Simply: What a Design Pattern Is
Explanation
What interviewers look for
Correct grouping with a couple of examples in each, ideally with the one-line question each family answers.
Follow-up questions
- Which family does Decorator belong to, and why?
- Which patterns from each family have you used?
More most-asked Design Patterns questions
- Explain the SOLID principles.
- What is a design pattern, and why are they useful?
- What is the difference between dependency inversion, dependency injection and inversion of control?
- Why is composition often preferred over inheritance?
- What is dependency injection, and what forms does it take?
- Explain the Factory Method pattern and how it differs from a simple factory.
- What problem does the Builder pattern solve? Show an example.
- How do you implement a Singleton, and why is it often considered an anti-pattern?