Introduction
In 1994, four computer scientists — Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides — published a book that would forever change how software engineers think about their problems. “Design Patterns: Elements of Reusable Object-Oriented Software” cataloged 23 recurring solutions to recurring problems in object-oriented development. The community nicknamed them the Gang of Four (GoF).
Three decades later, in a world of public cloud, hybrid architectures, Kubernetes, serverless, globally distributed teams and microservices that communicate through events, those same patterns are still a reference. Not because the world stood still. Because the fundamental problems of software have not changed — only the scale and the environment in which they appear have changed.
This article explores:
- Why software architecture is necessary — and what happens when it is ignored
- The origin and purpose of GoF — historical context, motivations and the structure of the 23 patterns
- How patterns apply regardless of language — GoF is not Java, nor C++; it is a design language
- The cloud and microservices revolution — how the classic patterns evolved and which new ones emerged
- Development and maintenance teams — why architecture is the link that keeps systems alive for more than one generation of developers
Who this article is for: developers with hands-on experience who want to raise their problem-solving reasoning to the level of software architecture.
📦 Source code: The complete implementation for this article is in the blog-zocateli-sample repository on GitHub. Clone it, explore it and adapt it to your context.
Why Software Architecture Matters
Software without architecture: the invisible cost
Imagine a banking system built by 50 developers over 8 years, without any architectural convention. Each developer solved problems in their own way. The result is what the industry calls a Big Ball of Mud — a shapeless mass where any change can break something anywhere.
This is not a hypothetical scenario. It is the natural state of systems that grow without architectural intent. The symptoms are recognizable:
- Invisible coupling: changing the payments module breaks the reporting module, and nobody knows why
- Tribal knowledge: only 2 developers know how that part “really works”
- Fear of deploying: “no deploys on Friday” became culture because nobody trusts the system
- Constant regression: every new feature seems to bring 3 old bugs back
- Slow onboarding: a new developer takes 6 months to become productive
Architecture is not what you do before writing code — it is the intent that guides every design decision throughout the entire life of the system.
What is software architecture, after all?
Martin Fowler defines software architecture as “the important stuff, the decisions that are hard to change” in a system. Ralph Johnson defines it as “the shared understanding that the developers have of how the system is organized”.
These definitions reveal two dimensions of architecture:
- Technical: modularity, coupling, cohesion, contracts between components, data flow, failure handling
- Social: a common vocabulary between people, conventions that allow a team of 20 to work consistently
The second dimension is frequently ignored — and that is exactly where the GoF patterns shine.
The cost of architectural technical debt
Architectural technical debt is different from, and more serious than, code-level technical debt. Refactoring a method takes an afternoon. Changing the architecture of a system in production can take months, with high risk. That is why wrong architectural decisions compound interest quickly:
| |
Architecture does not eliminate technical debt — but it steers it and makes it visible and manageable.
The Origin of the Gang of Four
Historical context: the object-oriented software crisis
By 1994, object-oriented programming had lived through its hype peak. C++, Smalltalk and, more recently, Java promised that inheritance, encapsulation and polymorphism would solve every code reuse problem. The promise did not fulfill itself.
The problem was not object orientation itself — it was that developers had no shared vocabulary to express how to use OO tools. Every project reinvented the same solutions for the same problems. A developer experienced in Smalltalk had consolidated solutions for “how to decouple an algorithm from its concrete implementations” — but those solutions lived in their head, not in books.
Gamma, Helm, Johnson and Vlissides realized they were independently arriving at the same solutions for the same kinds of problem. The idea for the book was born at an OOPSLA conference in 1990, when Erich Gamma and Richard Helm exchanged notes about recurring patterns. Writing took 4 years.
Christopher Alexander’s influence
The authors were explicitly inspired by Christopher Alexander, an architect (of physical buildings, not software) who in 1977 published “A Pattern Language” — a catalog of 253 recurring patterns in urban and building architecture, from city design to window placement.
Alexander’s central idea: recurring problems in a context have recurring solutions that can be named, documented and communicated. When an architect says “this room needs a double-height ceiling”, every other architect knows exactly what that means — without explaining it from scratch.
GoF applied this idea to software: by saying “use a Strategy here”, you communicate an entire design structure in a single word.
The structure of a GoF pattern
Each of the 23 patterns follows a consistent format:
| Field | Description |
|---|---|
| Name | The vocabulary — “Strategy”, “Factory”, “Observer” |
| Intent | What the pattern does, in one sentence |
| Also Known As | Alternative names |
| Motivation | A concrete scenario that justifies the pattern |
| Applicability | When to use it |
| Structure | Class diagram (UML) |
| Participants | The classes and their responsibilities |
| Collaborations | How the participants interact |
| Consequences | Trade-offs — what you gain and what you give up |
| Implementation | Implementation notes, variations |
| Sample Code | C++ in the original book |
| Related Patterns | Connections to other patterns |
The Consequences field is the most ignored and the most valuable. Every pattern has a cost. Knowing the cost is what separates an architect from someone who just applies patterns mechanically.
The 23 GoF Patterns
The 23 patterns are divided into three categories, based on the kind of problem they solve:
Creational Patterns — How Objects Are Created
They encapsulate and abstract the object creation process. The goal is to decouple the code that uses an object from the code that instantiates it.
Factory Method
Defines an interface for creating an object, but lets subclasses decide which class to instantiate.
| |
Abstract Factory
Creates families of related objects without specifying their concrete classes.
| |
Builder
Separates the construction of a complex object from its representation.
| |
Prototype
Creates new objects by copying (cloning) an existing object.
| |
Singleton
Ensures a class has only one instance and provides global access to it.
| |
Structural Patterns — How Objects Are Composed
They deal with the composition of classes and objects to form larger structures while keeping flexibility and efficiency.
Adapter
Converts the interface of a class into another interface clients expect.
| |
Decorator
Adds responsibilities to an object dynamically, without changing its class.
| |
Facade
Provides a simplified interface to a complex subsystem.
| |
Proxy
Provides a surrogate for another object to control access to it.
| |
Composite, Bridge, Flyweight
The remaining structural patterns solve equally common problems:
- Composite — treats individual objects and collections uniformly (menu trees, hierarchical categories, mathematical expressions)
- Bridge — separates abstraction from implementation so both can evolve independently (database drivers, report renderers)
- Flyweight — efficiently shares objects that occur in large numbers (characters in a text editor, particles in games)
Behavioral Patterns — How Objects Interact
They deal with communication between objects and the distribution of responsibilities.
Strategy
Defines a family of algorithms, encapsulates each one and makes them interchangeable.
| |
Observer
Defines a one-to-many dependency between objects: when one changes state, all its dependents are notified.
| |
Command
Encapsulates a request as an object, allowing operations to be parameterized, queued, logged and undone.
| |
Chain of Responsibility, Template Method, State, Iterator, Mediator, Visitor, Memento, Interpreter
The remaining behavioral patterns cover equally recurring problems:
| Pattern | Problem it solves | Modern use |
|---|---|---|
| Chain of Responsibility | Processes a request by passing it along a chain of handlers until it is handled | ASP.NET Core Middleware, pipelines |
| Template Method | Defines the skeleton of an algorithm in a base class, leaving parts to subclasses | Test base classes, ETL pipelines |
| State | Lets an object change its behavior when its state changes | State machines, orders, workflows |
| Iterator | Traverses a collection without exposing its internal structure | IEnumerable<T>, foreach, yield return |
| Mediator | Objects communicate through a central mediator — reduces direct dependencies | MediatR, message broker, event bus |
| Visitor | Adds operations to objects without modifying their classes | AST visitors, tree transformations |
| Memento | Captures and restores an object’s internal state without breaking encapsulation | Undo/redo, checkpoints, snapshots |
| Interpreter | Defines a grammar and an interpreter for it | DSLs, business rule validation |
GoF Is Language-Independent
A common misconception is treating the GoF patterns as “Java patterns” or “C++ patterns”. The original book was written with examples in C++ and Smalltalk. But the patterns are design concepts, not APIs.
The same problem, different languages
Observer in JavaScript:
| |
Strategy in Python:
| |
Factory in Go:
| |
Why does this matter in cross-functional teams?
When you have a team with C#, Go, Python and TypeScript developers, the GoF patterns are the lingua franca of design. The conversation:
“We need an Observer here, because several modules need to react when the order status changes”
…makes sense to everyone, regardless of the language each person uses day to day. Without this common vocabulary, the conversation would be:
“We need a class that, when the status changes, calls a list of other classes that have a method that… you get it”
The Cloud and Microservices Era
How the cloud changed the context, not the problems
Moving to the cloud brought new problems of scale, availability and distribution. But the fundamental problems — coupling, cohesion, separation of concerns — did not change. What changed was where the problems appear and how much a bad decision costs.
| Era | Environment | Cost of failure | Scale | Core pattern |
|---|---|---|---|---|
| Monolith | Single server | Contained | Vertical | Classic GoF |
| SOA | Internal network | Moderate | Moderate | Adapter, Facade |
| Microservices | Distributed cloud | High (cascading) | Unlimited horizontal | Distributed patterns |
| Serverless | Ephemeral cloud | Variable | Auto-scaling | Stateless by design |
| Hybrid | Mixed | Complex | Heterogeneous | Infrastructure abstraction |
New patterns for new problems
The cloud brought a new generation of patterns, many of them built on GoF principles:
Circuit Breaker — the Proxy applied to external calls. It detects cascading failures and stops calls to degraded services:
| |
Sidecar — the Decorator applied at the infrastructure level. An auxiliary process that runs next to the main service, adding responsibilities (logging, mTLS, rate limiting) without changing the service code:
| |
Saga — Command + Observer applied to distributed transactions. Since there is no ACID transaction across microservices, the Saga orchestrates a sequence of local transactions with compensations for failures:
| |
CQRS (Command Query Responsibility Segregation) — Command + Strategy applied to reads/writes:
| |
Cloud vs On-Premises: the most expensive architectural decision
The cloud vs on-premises dichotomy is not technical — it is strategic and has deep architectural implications:
| Dimension | Cloud | On-Premises | Hybrid |
|---|---|---|---|
| Scalability | Elastic (pay per use) | Limited by hardware | Burst to cloud |
| Latency | Depends on the region | Predictable, low | Routing complexity |
| Compliance | Varies by cloud/region | Full control of data | Sensitive data: on-prem |
| CapEx vs OpEx | OpEx dominant | CapEx dominant | Mixed |
| Vendor lock-in | High (PaaS/SaaS) | Low | Moderate |
| Ops complexity | Low (managed) | High (infra team) | Very high |
| Supporting patterns | Adapter (abstract the cloud SDK) | Not needed | Anti-Corruption Layer |
Adapter as anti-lock-in: teams that build directly on cloud providers throughout the code get stuck. The solution is to use the Adapter pattern to abstract the infrastructure:
| |
Development Teams and Maintenance Teams
This is perhaps the most underestimated dimension of software architecture. Every successful system ends up being maintained by people who did not build it. Sometimes by a different team. Sometimes years later. Sometimes by developers with very different profiles and skills.
The real lifecycle of a system
| |
Why patterns are the system’s institutional memory
When a new developer arrives at a system that uses the GoF patterns consistently, they do not need to reinvent how to read the code. On seeing IStrategy as a dependency injected into a class, they immediately understand:
- This class has behavior that can vary
- The implementations are in other files, named XXXStrategy
- To add a new behavior, just create a new implementation
- Existing code does not need to change (Open/Closed Principle)
Without this shared vocabulary, the same scenario produces:
“Why is there an interface here with only one implementation? This looks like waste.”
…followed by a well-intentioned refactoring that removes the abstraction, creating coupling, making other code harder to test, and breaking behavior in production.
Team diversity: an asset with a coordination cost
Modern software teams are cross-functional by necessity:
| Role | Main focus | Architecture perspective |
|---|---|---|
| Backend Developer | Business logic, APIs | Domain patterns, CQRS, Event Sourcing |
| Frontend Developer | UX, rendering performance | Component patterns, global state |
| Data Engineer | Pipelines, ETL, analytics | Data patterns, streaming |
| DevOps / SRE | Availability, observability | Infra patterns, resilience |
| Solutions Architect | Integration, domain | Enterprise patterns, bounded contexts |
| Tech Lead / Staff Eng | Platform decisions | All levels |
| L1/L2 Support | Triage, quick fixes | Maintainability patterns |
The risk of teams without a common language:
- A Data Engineer implements a pipeline with business logic that duplicates what already exists in the domain
- A DevOps engineer creates deploy scripts that assume implementation details the backend team has changed
- L2 support fixes a bug in the Adapter without understanding there are multiple implementations, breaking another one
Documented architecture — with named patterns, decision records (ADRs) and context diagrams — is what allows people with different perspectives to contribute without collision.
Architecture Decision Records (ADRs)
For each relevant architectural decision, document:
| |
That record is worth gold to the maintenance team 3 years later. Without it, the question “why is this interface here?” has no answer — and the improvised answer is usually wrong.
Principles That Underpin Everything
The GoF patterns do not exist in a vacuum. They are practical expressions of more fundamental principles. The most important ones:
SOLID
| Principle | Definition | GoF pattern that expresses it |
|---|---|---|
| S — Single Responsibility | One class, one reason to change | Facade (isolates responsibilities), Command |
| O — Open/Closed | Open for extension, closed for modification | Strategy, Decorator, Observer |
| L — Liskov Substitution | Subclasses must be substitutable for their bases | Factory Method, Template Method |
| I — Interface Segregation | Small, focused interfaces | Adapter, Proxy |
| D — Dependency Inversion | Depend on abstractions, not on implementations | All patterns via DI |
Cohesion and Coupling
High cohesion, low coupling — perhaps the oldest and most violated principle of software engineering.
- High cohesion: each module/class does one thing well. Facade, Strategy and Command promote cohesion.
- Low coupling: modules have few dependencies on each other. Observer, Mediator and Event Bus reduce coupling.
Law of Demeter (Principle of Least Knowledge)
A module should know only its immediate collaborators — not the collaborators of its collaborators.
| |
Pitfalls: When Patterns Get in the Way
Patterns applied without judgment are as harmful as no patterns at all. The most common anti-patterns:
Overengineering (“patternitis”)
| |
Singleton as a global variable
Singleton is the most abused pattern. When everything is a Singleton, you essentially recreate global state:
| |
Premature abstraction
Do not use patterns for problems you do not have yet:
“You Aren’t Gonna Need It” (YAGNI) — do not add complexity for hypothetical needs.
The rule of thumb: when the problem appears for the second time, consider a pattern. When it appears for the third time, apply it.
Conclusion
The GoF patterns are turning 30 and remain on the required reading list of software engineers around the world — not out of nostalgic reverence, but because the problems they solve have not disappeared. Naming solutions to recurring problems is one of the most powerful tools in engineering.
What changed were not the fundamental problems, but the context in which they appear:
- In a monolith, a poorly applied Observer produces code that is hard to read. In a distributed system, it produces a cascade of failures that takes down multiple services.
- In a one-developer project, a Singleton without DI is an annoyance. In a team of 50 people, it creates hidden dependencies nobody sees until the system goes down in production.
- In a static on-premises environment, coupling to a specific implementation is manageable. In the hybrid cloud ecosystem, it creates migration debt measured in months.
Software architecture — especially its named patterns — is what allows systems to survive beyond their original generation of developers. It is what lets a developer who joins a project today understand the design intentions of whoever built the system 5 years ago. It is what lets the maintenance team fix a bug without accidentally introducing three new ones.
Learn the 23 GoF patterns. Not to apply all of them — but to have a vocabulary that lets you think, communicate and document design decisions precisely. Someone will maintain tomorrow the software you write today. Leave clear messages.
Read Also
- REST API Design: HTTP Verbs and Parameter Binding
- REST API Pagination with C# and EF Core: Practical Guide
- Database Bottlenecks: Messaging and Pagination
- Asynchronous Programming in C#: async/await and Threads
References
- Design Patterns: Elements of Reusable Object-Oriented Software — Gamma, Helm, Johnson, Vlissides (1994) — The original Gang of Four book
- A Pattern Language — Christopher Alexander (1977) — The intellectual origin of software patterns
- Refactoring: Improving the Design of Existing Code — Martin Fowler — GoF patterns in refactoring practice
- Patterns of Enterprise Application Architecture — Martin Fowler — Patterns beyond GoF for enterprise applications
- Building Microservices — Sam Newman — Architecture patterns for distributed systems
- Cloud Design Patterns — Microsoft — Official catalog of cloud patterns (Circuit Breaker, Sidecar, CQRS, Saga, etc.)
- Architecture Decision Records — Michael Nygard — ADRs as architectural institutional memory
- SOLID Principles — Robert C. Martin — The theoretical foundation connecting the GoF patterns
- blog-zocateli-sample repository — DesignPatterns — Complete source code for the examples in this article

By commenting, you agree to our Privacy Policy, Terms of Use, Data Deletion Policy.