Software Design Patterns
An overview of Software Design Patterns
What are Software Design patterns?
A design pattern is a reusable solution to a problem that comes up again and again in software design. It’s not a library you install or a class you copy-paste — it’s a template for how to approach a problem, and the actual implementation will look different in every project.
Think of it like an architect’s blueprint for solving a structural challenge. The blueprint isn’t the building — but any builder can follow it and adapt it to their specific constraints. Similarly, a design pattern isn’t code — it’s the strategy behind the code.
The formal definition from the GoF book puts it well: “A design pattern names, abstracts, and identifies the key aspects of a common design structure that make it useful for creating a reusable object-oriented design.”
For example, if you’ve ever written code where only one instance of something should exist — a database connection pool, a logger, a configuration manager — you’ve encountered the problem that the Singleton pattern solves. The pattern gives that solution a name and a structure you can apply consistently.
Design patterns are formalized best practices. They won’t write your code for you, but they give you a proven starting point — so you spend less time reinventing solutions and more time solving the problems unique to your project.
Why should you learn Design patterns?
You can write working software without ever learning a design pattern. But knowing them makes you significantly more effective. Here’s why -
- Solve complex problems with proven approaches — Many of the hard problems in software — managing object creation, decoupling components, handling state changes — have already been solved. Design patterns give you battle-tested strategies for these problems, so you spend less time struggling and more time shipping.
- Don’t reinvent the wheel — Most of the problems you’ll encounter are not new. Someone has already faced the same issue, worked through it, and documented a solution. You don’t need to build from scratch — you just need to learn to recognize the pattern.
- Communicate ideas clearly — Saying “let’s use a Strategy pattern here” conveys a full design in three words. Without patterns, you’d need to explain the entire structure. They give your team a shared vocabulary that makes design discussions faster and more precise.
- Catch issues earlier — Patterns encode lessons from thousands of real-world projects. Using them helps you avoid pitfalls that you might not discover on your own until much later in development.
- Improve code readability — When your codebase uses well-known patterns, any engineer familiar with them can understand the structure quickly — even if they’ve never seen your project before. Patterns make intent obvious.
The Gang of Four
In 1994, four software engineers — Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides — published Design Patterns: Elements of Reusable Object-Oriented Software. They are commonly referred to as the Gang of Four, or GoF.
The book catalogued 23 design patterns organized into three categories — Creational, Structural, and Behavioral. What made it groundbreaking was that it gave the industry a shared language for solutions that experienced developers were already using informally. Before GoF, two engineers might solve the same problem the same way and have no common name for it.
Get Vivek Mittal’s stories in your inbox
Join Medium for free to get updates from this writer.
Published over three decades ago, the book remains one of the most referenced texts in software engineering — and the 23 patterns it documented are still the foundation of how we talk about software design today.
Types of Design Patterns
The GoF organized their 23 patterns into three categories based on what aspect of software design they address:
- Creational (5 patterns) — Deal with how objects are created. Instead of instantiating objects directly, these patterns give you control over the creation process — making it more flexible, decoupled, or constrained as needed. Examples: Singleton, Factory, Builder.
- Structural (7 patterns) — Deal with how objects are composed. These patterns help you assemble classes and objects into larger structures while keeping those structures flexible and efficient. Examples: Adapter, Decorator, Facade.
- Behavioral (11 patterns) — Deal with how objects communicate. These patterns define clear ways for objects to interact and distribute responsibility, so no single object does too much. Examples: Strategy, Observer, State.
You’ll notice the Behavioral category is the largest — that’s because communication between objects is where most of the complexity in software lives.
Commonly used Design Patterns
You don’t need to memorize all 23 patterns to get started. Here are five you’ll encounter most often:
- Singleton (Creational) — Ensures a class has only one instance and provides a global access point to it. Common use cases include loggers, configuration managers, and connection pools. Singleton is often used alongside other patterns like Factory and Facade, where you want exactly one instance managing the creation or access layer.
- Factory (Creational) — Lets you create objects without specifying their exact class. The calling code asks for a product by type, and the factory decides which concrete class to instantiate. This decouples your code from specific implementations — so adding a new type doesn’t require changes everywhere.
- Strategy (Behavioral) — Lets you swap an algorithm at runtime. For example, a compression module might use ZIP for speed or RAR for size, selected based on user preference. The calling code stays the same — only the strategy changes.
- Adapter (Structural) — Connects two incompatible interfaces by wrapping one in a new interface the client expects. Think of it like a power adapter when you travel — the plug doesn’t change, the adapter bridges the gap.
- Proxy (Structural) — Places a stand-in object in front of a real one to control access. A proxy might fetch data from a REST API on the first call, then return a cached copy on subsequent calls — without the client knowing the difference.
The table below shows all 23 GoF patterns organized by category.
Anti-Patterns
If design patterns are proven solutions, anti-patterns are the opposite — commonly used approaches that seem effective but consistently lead to bad outcomes. They look right at first. They fail later. And because they’re so widespread, developers often adopt them without questioning — especially under time pressure.
The term “anti-pattern” was coined by Andrew Koenig in 1995, just a year after the GoF book. It was a natural counterpart — if we’re going to formalize what works, we should also formalize what doesn’t.
What separates an anti-pattern from a simple bad habit? Two things:
- It’s a widely used practice that appears reasonable but produces more harm than good.
- A better, documented solution already exists.
If only the first condition is true, it’s just a bad practice. An anti-pattern specifically means there’s a known better way — and people keep choosing the worse one anyway, often because the anti-pattern is easier to reach for in the moment.
A classic example is the God Object (also called a Kitchen Sink class) — a single class that takes on far too many responsibilities. Need to add a feature? Put it in the God Object. Need a utility method? God Object. It starts convenient, and for a while it works. But over time it becomes impossible to test, debug, or extend. Every change risks breaking something unrelated because everything is coupled together.
The fix is well-known: apply the Single Responsibility Principle and break the God Object into focused, smaller classes — each with one clear job. This is why knowing anti-patterns matters. For every anti-pattern, a documented, proven alternative exists.
Anti-patterns often emerge from insufficient experience, tight deadlines, or simply not knowing that a better approach exists. Learning to recognize them is just as valuable as knowing design patterns — it helps you spot structural problems early, before they become expensive to fix.
What’s Next
This is the first post in a series where we’ll cover each of the 23 GoF design patterns in detail — from concept to working code. Every post will include practical examples with source code you can clone, run, and reference. The primary language will be Java, with examples in C++ or Swift where it adds clarity.
You don’t need to master all 23. Focus on the ones you encounter most — Singleton, Factory, Strategy, Observer, Adapter — and build a working understanding of the rest. Knowing when to reach for a pattern matters more than memorizing all of them.
Recommended reading:
- Design Patterns: Elements of Reusable Object-Oriented Software — the original GoF book. Dense but definitive.
- Head First Design Patterns by Eric & Elisabeth Freeman — more approachable, visual, and my personal favorite.
Posts in this series:
Written & edited by — Vivek Mittal | LinkedIn







