What are the categories of design patterns?
Design patterns fall into three categories: creational, structural, and behavioral. That grouping comes from the Gang of Four book. It cataloged 23 patterns and sorted them by the problem each one solves. Creational patterns deal with how objects get made. Structural patterns deal with how objects are composed. Behavioral patterns deal with how objects talk to each other. Many teams add a fourth category, concurrency, for patterns that coordinate work across threads.
Quick Overview
| Category | The problem it solves | Patterns you should know |
|---|---|---|
| Creational | Making objects without hard-coding the class | Factory Method, Abstract Factory, Builder, Singleton |
| Structural | Composing objects into larger structures | Adapter, Decorator, Facade, Proxy, Composite |
| Behavioral | Assigning responsibility and communication | Strategy, Observer, Command, State, Template Method |
| Concurrency | Coordinating work across threads | Producer-Consumer, Thread Pool, Read-Write Lock |
Creational patterns
These control how objects are created. The goal is that code asking for an object does not need to know which concrete class it gets.
Factory Method puts object creation behind a method that subclasses override. Abstract Factory does the same for a whole family of related objects. Builder assembles an object step by step. That helps when a constructor would otherwise take ten arguments. Singleton restricts a class to one instance.
Singleton is the one to be careful with. It is the most recognized pattern and the most criticized. A single global instance makes code hard to test.
Structural patterns
These describe how to compose objects into bigger structures without a rigid inheritance tree.
Adapter wraps a class so it matches an interface your code already expects. Decorator wraps an object to add behavior without changing the original class. Facade puts one simple interface in front of a complicated subsystem. Proxy stands in for another object and controls access to it. Composite lets you treat a single object and a whole tree the same way.
If you have ever wrapped a third-party client so the rest of your code does not depend on it, you have written an Adapter.
Behavioral patterns
These deal with responsibility: which object does what, and how they communicate.
Strategy makes an algorithm swappable at runtime. Observer lets objects subscribe to events on another object. That is the idea behind most event systems. Command turns a request into an object. It can then be queued, logged, or undone. State lets an object change behavior when its internal state changes. Template Method defines the skeleton of an algorithm and leaves specific steps to subclasses.
Strategy and Observer come up more than any other pattern in interviews. Know both well enough to write one.
The fourth category: concurrency patterns
Concurrency patterns are not in the Gang of Four book. They were cataloged later. They solve a different problem: coordinating work safely across threads.
Producer-Consumer separates code that creates work from code that processes it. A queue sits in between. Thread Pool reuses a fixed set of threads instead of creating one per task. Read-Write Lock lets many readers proceed together but gives writers exclusive access.
You will see design patterns described as three categories in some sources and four in others. Both are correct. Three is the Gang of Four classification. The fourth is a later addition that most teams treat as standard.
Which ones actually come up in interviews
You do not need all 23. In an object-oriented design round, a small set does most of the work.
- Strategy, when the question asks you to make behavior swappable
- Observer, when one change has to notify several parts of the system
- Factory, when object creation would otherwise be scattered across the code
- Adapter, when two interfaces do not match
- Decorator, when features stack in combinations
The mistake to avoid is naming a pattern you cannot implement. Interviewers follow up by asking you to write it. A pattern name without working code scores worse than saying nothing.
How to Prepare
Learn the five patterns above properly before the rest. Being able to write Strategy and Observer from memory is worth more than recognizing all 23.
Practice applying them, not reciting them. In object-oriented design questions they are a solution you reach for, not a definition you state.
For database work, the patterns are different. Schema and data-layer patterns are a separate topic from the Gang of Four set. See database design patterns.
For distributed systems, so are the patterns. System design rounds use patterns like circuit breaker and sharding. See key system design patterns for tech interviews and, for service architecture, essential microservices patterns.
For a full treatment of the object-oriented set, Grokking Design Patterns for Engineers and Managers works through each pattern with code. For the distributed systems set, see Grokking the System Design Patterns.

GET YOUR FREE
Coding Questions Catalog

$123

$197

$72