About this book
Design Patterns: Elements of Reusable Object-Oriented Software was published by Addison-Wesley in 1994. Its four authors, Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides, were soon nicknamed the Gang of Four, and the book itself is still usually called the GoF book. It appeared at the moment when object-oriented programming was moving from research labs and a few enthusiastic teams into ordinary industrial practice. C++ was spreading quickly, Smalltalk had a loyal following, and Java was about to arrive. Many programmers had learned the mechanics of classes and inheritance but had little sense of how to arrange objects into designs that would survive change.
The book sets out to answer a practical question. Experienced object-oriented designers seem to produce flexible, reusable designs more easily than beginners do. What do they know that the beginners do not? The authors' answer is that experts do not design every system from first principles. They carry in their heads a stock of solutions that have worked before, and they recognise when a new problem resembles an old one. The book tries to write that stock down.
The result is a catalogue of twenty-three design patterns. Each pattern names a recurring design problem, describes a solution in terms of cooperating classes and objects, and states the costs and benefits of applying it. The names, such as Observer, Strategy, Composite, Adapter and Factory Method, have become part of the working vocabulary of the whole software industry. Many programmers who have never opened the book use its words every week.
The intended reader is a working programmer or designer who already knows an object-oriented language and has written enough code to have felt the pain of rigid designs. The book is not a beginner's tutorial. It assumes the reader can follow class diagrams and short code samples in C++ or Smalltalk. It is also not a textbook on any one method. It sits between theory and practice, offering named pieces of design that can be combined in many ways.
The book has three parts in effect. An introductory chapter explains what a design pattern is, how the catalogue is organised, and what general principles of object-oriented design the patterns express. A second chapter works through a case study, the design of a document editor, showing several patterns meeting real problems together. The remaining and largest part is the catalogue itself, arranged into creational, structural and behavioural groups.
It is worth noticing how modest the book's claims are. The authors do not say they invented these designs. They say they found them, repeatedly, in systems built by many people, and they cite those systems. The patterns are presented as observations, the way a naturalist might describe recurring forms in plants. That modesty is part of why the catalogue has lasted: it describes what working designers actually did, not what a theory said they should do.
This study edition does not retell the catalogue. Its aim is to help a reader understand why the book was written, what its central ideas are, how those ideas fit together, where they came from, what has been said against them, and how to read the book itself with profit.
The authors
The four authors came from different places but shared a background in object-oriented research and framework building in the late 1980s and early 1990s. That shared background matters, because the patterns were not invented at a desk. They were noticed in working systems, especially in user-interface frameworks, editors and drawing tools that the authors and their colleagues had built.
Erich Gamma
Erich Gamma is Swiss. His doctoral work at the University of Zurich concerned an application framework written in C++, and the experience of building and refining that framework fed directly into the pattern catalogue. Many of the patterns are the kind of thing one notices after rewriting the same framework several times. Gamma later worked on object-oriented tools in industry and became widely known for two other contributions: with Kent Beck he wrote JUnit, the small unit-testing framework for Java that shaped testing practice across many languages, and he led work on the Java development tools in the Eclipse platform. Later still he worked on code editors at Microsoft. Across all of this his interest stayed the same: tools and frameworks that make designers more effective.
Richard Helm
Richard Helm is Australian and worked in object-oriented research at IBM in the early 1990s, where he studied how objects collaborate and how such collaborations could be described formally. That concern with collaboration, rather than single classes, runs through the book. A pattern is almost never one class; it is a small society of objects with distinct roles. Helm later moved into consulting and technology management.
Ralph Johnson
Ralph Johnson spent his career as a professor of computer science at the University of Illinois at Urbana-Champaign. He was a leading figure in the Smalltalk community and wrote influential work on frameworks, including a well-known paper with Brian Foote on how reusable classes are designed. His research group at Illinois also produced some of the earliest work on automated refactoring, which led to the Refactoring Browser for Smalltalk. Johnson's interest in frameworks explains a recurring theme in the book: patterns are the small reusable ideas from which large reusable frameworks are built.
John Vlissides
John Vlissides worked at IBM's research centre in New York and had earlier built a well-known user-interface toolkit in C++ at Stanford. He wrote a regular column on patterns for a C++ magazine and later a short companion book, Pattern Hatching, which reflects on how the patterns were found and how they are misunderstood. He died in 2005. Many in the patterns community remember him as the member of the group most concerned with explaining the ideas clearly to working programmers.
The setting
The four met through the object-oriented conference circuit, especially the yearly OOPSLA conference, where workshops on design and frameworks were common. Before the book there was already a small movement around patterns in software. Kent Beck and Ward Cunningham had presented a short paper in 1987 on using pattern languages for user-interface design, inspired by the architect Christopher Alexander. Gamma's thesis had already used pattern-like descriptions. The book gathered these threads into one carefully edited catalogue. It was released in late 1994 and sold in very large numbers, an unusual result for a dense technical book.
The shape of the argument
The book is mostly a reference work, but it has an argument, and it is worth seeing the argument before using the reference. The argument runs roughly like this. Designing object-oriented software is hard, and designing reusable object-oriented software is harder. The hard part is not syntax but deciding which objects should exist, what each should be responsible for, and how they should depend on each other. Good designers solve these questions by reusing proven arrangements. Those arrangements can be named, described and taught. Once named, they let designers think and talk at a higher level, and they make existing designs easier to understand.
The introduction as a short course in design
The opening chapter is the most quoted part of the book, and for good reason. Before the catalogue begins, the authors explain how objects are found, how granularity is decided, how interfaces are specified, and how inheritance and composition differ. They state two principles that shape almost every pattern: rely on abstract interfaces rather than concrete classes, and prefer assembling objects to inheriting from classes. They also list common causes of redesign, such as committing to a specific class at creation time, depending on a particular platform or algorithm, or coupling classes tightly, and they show which patterns address which causes. A reader who absorbs only this chapter will already design differently.
The case study as a demonstration
The second chapter takes a single concrete project, a document editor the authors call Lexi, and walks through its design problems: how to represent a document's structure, how to format it, how to add borders and scroll bars, how to support several look-and-feel standards and several window systems, how to support undoable commands, and how to perform analyses such as spell checking. Each problem is solved by one or more patterns. The point is not the editor. The point is that patterns rarely appear alone; they interlock, and a real design is a weave of several of them.
The catalogue as the body
The catalogue is organised along two axes. The first is purpose. Creational patterns deal with how objects come into being. Structural patterns deal with how classes and objects are composed into larger structures. Behavioural patterns deal with how responsibility and communication are distributed among objects. The second axis is scope: whether the pattern works mainly through class inheritance, fixed at compile time, or mainly through object relationships, which can change at run time. Most of the patterns are object patterns, which already tells the reader something about the authors' preferences.
Every entry follows the same template. It gives the pattern's name and classification, its intent in a sentence or two, other names it is known by, a motivating scenario, a statement of when it applies, a structure diagram, the participants and how they collaborate, the consequences of using it, notes on implementation, sample code, examples of known uses in real systems, and related patterns. This uniform template is part of the book's argument. It insists that a pattern is not just a diagram or a snippet. A pattern includes the problem, the forces in tension, and the trade-offs. Without those, it is only a recipe.
How to see the whole
The best way to hold the book in mind is as a small number of ideas expressed in many forms. Again and again a pattern takes something that would normally be fixed in code, such as which class is created, which algorithm runs, which object receives a request, or how a structure is traversed, and turns it into an object that can be passed around, swapped or combined. Once that move is visible, the twenty-three patterns stop looking like a list to be memorised and start looking like variations on a theme.
Idea one: a pattern is a named solution in a context
The most important idea in the book is also the simplest. A design pattern is a description of a recurring problem, the core of a solution to it, and the consequences of that solution, packaged under a name. The authors borrowed the notion from Christopher Alexander, who had described patterns in towns and buildings, such as a window place where light falls on a seat, or a set of small public squares. Alexander's insight was that good built environments share recurring arrangements that can be described in a way that leaves room for endless variation in the details.
In software, the same thing is true. Consider a weather station that measures temperature, and several displays that show it: a dial, a graph, a log file. Each time the reading changes, every display must update. A beginner might have the station call each display directly. Then adding a new display means editing the station. The experienced designer instead has displays register themselves with the station, which simply tells all registered listeners that something changed. That arrangement has a name, Observer, and once it has a name, two designers can agree on it in one word instead of ten minutes at a whiteboard.
Why names matter
Names do three kinds of work. First, they compress. Saying that a menu uses Command objects tells a listener a great deal about the design in very little time. Second, they make knowledge transferable. A junior programmer who learns the name can look it up, read the consequences and avoid known mistakes. Third, they make existing code readable. A class called something like EventListener or ShapeVisitor carries its design intent on its face. Programmers who know the vocabulary can enter a large codebase and recognise its skeleton quickly.
What a pattern is not
A pattern is not a piece of reusable code. It cannot simply be downloaded and linked. It is a design idea that must be adapted to each situation. Two implementations of Observer in two systems may share no lines of code at all. A pattern is also not an algorithm. Algorithms like quicksort solve computational problems with precise steps. Patterns solve design problems about how responsibilities are divided, and they leave many decisions open. Finally, a pattern is not a rule. It is a tool with costs, and the catalogue is careful to say when not to use each one.
This distinction is often lost. Many people treat the twenty-three patterns as boxes to tick, or as a standard library of classes. The book itself never presents them that way. It presents them as condensed experience, to be understood rather than copied.
Idea two: depend on interfaces, not on concrete classes
The first of the book's two great principles is that client code should depend on abstract interfaces rather than on specific implementation classes. In the book this appears as a short motto, which we give here as our single quotation from the work: program to an interface, not an implementation.
The reasoning is straightforward. When code names a concrete class, it is tied to that class. If the class changes, or if a different class is needed in some situations, the client must be edited. When code names only an abstract type, such as a Shape with a draw operation, any class that satisfies that type can be used. The client does not know or care whether it is drawing a circle, a polygon or an image. New kinds of shape can be added without changing it.
An everyday analogy
Think of an electrical socket. An appliance is designed to the socket's interface: the shape of the plug, the voltage, the frequency. It does not care whether the electricity comes from coal, sunlight or a battery bank. Because both sides agree on a narrow interface, each can change independently. A software interface plays the same role. It is a contract that lets one side be replaced without disturbing the other.
Where it leads
Taken seriously, this principle has a direct consequence for object creation. If clients are not supposed to name concrete classes, then something else must decide which concrete class to instantiate. That is the problem the creational patterns solve. It also has a consequence for testing, which the book does not stress but which later practice made central: a class that depends only on interfaces can be tested with simple stand-in objects. Much of modern dependency injection and test-double practice grows from this root.
What it is confused with
The principle is sometimes misread as a demand that every class have a matching interface declaration. That leads to codebases where each class has a twin interface used only once, adding files without adding flexibility. The principle is about where variation is expected. If a part of the system genuinely needs to vary, hide it behind an abstraction. If it does not, a concrete class is fine. The interface is a tool for managing change, not a ritual.
Idea three: prefer composition to inheritance
The second great principle is to favour object composition over class inheritance. Inheritance lets a subclass reuse and extend a parent class. Composition lets an object get behaviour by holding references to other objects and delegating work to them. Both are forms of reuse. The authors argue that composition is usually the more flexible of the two.
Inheritance has real advantages. It is supported directly by the language, it is easy to see in code, and overriding a method is a quick way to change behaviour. But it has costs that grow with time. A subclass depends on the internals of its parent, so a change in the parent can break subclasses in surprising ways. The relationship is fixed at compile time, so an object cannot change its inherited behaviour while the program runs. And deep hierarchies multiply: if there are three kinds of window and two kinds of border, inheritance alone may require six classes, and adding a scroll bar option doubles that again.
An illustration
Imagine a coffee-ordering system. A plain coffee can have milk, sugar, foam or syrup in any combination. Building a subclass for each combination quickly becomes absurd. Instead, a coffee object can be wrapped by a milk object, which is wrapped by a sugar object, each adding its own cost and description and passing the rest to the object inside. Any combination is now possible with only one small class per ingredient, and combinations can be built at run time from a customer's order. This is the Decorator pattern, and it is a clear demonstration of composition beating inheritance.
Delegation as the engine
The book points out that composition becomes as powerful as inheritance when combined with delegation. An object receiving a request passes it to another object it holds, sometimes passing itself along so the delegate can call back. Several patterns, including State, Strategy and Visitor, depend on this technique. Delegation makes designs more dynamic and sometimes harder to follow, because behaviour is spread across several objects rather than visible in one class. The authors acknowledge this cost openly.
Where it leads
This principle outlived the specific patterns. Languages designed after the book, such as Go, deliberately left out class inheritance and offered composition and interfaces instead. Modern game engines commonly use component systems where entities gain behaviour by attaching components rather than by inheriting from deep hierarchies. Front-end user-interface libraries moved from inheritance-based widgets toward composed components. In each case the reasoning echoes the book: small parts combined freely are easier to change than tall trees of subclasses.
Idea four: find what varies and encapsulate it
Behind both principles lies a deeper habit of thought. Before designing, ask what in this system is likely to change. Then put each such thing behind a boundary so that change can happen in one place. The authors express this through their discussion of causes of redesign, and many later writers condensed it into a single phrase about encapsulating what varies.
Each pattern in the catalogue can be read as an answer to the question of what it lets vary. Strategy lets an algorithm vary. State lets behaviour vary with an object's internal condition. Abstract Factory lets a family of related products vary. Iterator lets the way of traversing a collection vary. Bridge lets an abstraction and its implementation vary independently. Observer lets the number and kind of dependent objects vary. Reading the catalogue with this lens makes it much easier to remember and to apply.
An example
A shipping system must compute delivery costs. Today it uses a flat rate. Next month it will need distance-based pricing, and later perhaps a partner's pricing service. If the cost calculation is written directly into the order class, each change means editing and retesting that class. If instead the order holds a pricing object and asks it for the cost, new pricing rules are just new pricing classes. The variation has been isolated. This is Strategy, but more importantly it is a way of thinking that applies even where no named pattern fits.
The danger of guessing
This idea has a shadow. A designer who tries to anticipate every possible change will wrap everything in abstractions and produce a system that is flexible in all the wrong places and hard to understand everywhere. The book's emphasis on consequences is meant to guard against this, but readers have not always listened. Later movements, especially the agile practices of the late 1990s, argued for adding flexibility only when a real need appears and using refactoring to introduce patterns at that point. That view complements the book rather than contradicting it. The patterns tell you what the flexible shape looks like; experience and evidence tell you when to adopt it.
Idea five: separating creation from use
The creational patterns address a specific tension. Good design says clients should depend on abstractions. But at some point a concrete object must be created, and the code that creates it must name a concrete class. The creational patterns move that decision to a single, controlled place, so that the rest of the system stays free of concrete dependencies.
The five creational patterns approach this from different angles. Abstract Factory provides an object whose job is to create a family of related objects, such as all the widgets for one look and feel, so that swapping the factory swaps the whole family consistently. Builder separates the step-by-step construction of a complex object from its final representation, so that the same construction process can produce different results. Factory Method lets a class defer to its subclasses the choice of which concrete object to create. Prototype creates new objects by copying an existing example rather than by naming a class. Singleton ensures a class has only one instance and gives a global point of access to it.
A plain analogy
Consider a restaurant kitchen. The waiter does not cook. The waiter passes an order to the kitchen, which decides how to produce the dish. If the restaurant changes its supplier or its chef, the waiter's job does not change. A creational pattern plays the kitchen's role: clients ask for an object of a certain kind, and a separate part of the system decides exactly how to make it.
What later practice did with it
Much of this territory was later taken over by dependency injection containers and configuration frameworks, which create objects and wire them together outside the classes that use them. Those tools did not make the creational patterns obsolete; they automated them. Understanding the patterns makes the containers less mysterious. At the same time, one creational pattern, Singleton, has become the most criticised in the book, because a global instance introduces hidden dependencies, makes testing harder and complicates concurrent code. The book does describe its costs, but many readers adopted it as a convenient global variable with a respectable name.
Idea six: wrapping and composing structures
The structural patterns concern how objects are put together into larger wholes. Several of them share a surprising feature: they place one object in front of another, presenting the same or a similar interface, and they differ mainly in why they do it.
Adapter converts one interface into another that a client expects, the way a travel plug adapter lets a device from one country use a socket in another. Decorator adds responsibilities to an object without changing its interface, as in the coffee example earlier. Proxy stands in for another object to control access to it, perhaps loading it lazily, checking permissions, or forwarding requests across a network. Facade offers a single simple interface to a complicated subsystem, like a reception desk that hides a large office. Bridge separates an abstraction from its implementation so the two can evolve independently. Flyweight shares fine-grained objects to save memory, for instance using one shared object for each letter of the alphabet rather than one per character in a long document.
Composite: the part that looks like the whole
Composite deserves special attention, because it captures one of the most useful ideas in software. It lets individual objects and groups of objects be treated through the same interface. A drawing program may have lines, circles and text, and it may let the user group shapes together. With Composite, a group is itself a shape. Moving, drawing or resizing a group simply passes the request to each member. Groups can contain groups. The same idea governs file systems, where a folder can contain files and other folders; user-interface trees, where panels contain widgets and other panels; and document structures, where sections contain paragraphs and subsections.
Why the similarity matters
Because Adapter, Decorator and Proxy can look nearly identical in a class diagram, readers often confuse them. The book's emphasis on intent resolves the confusion. The structure is the same; the purpose differs. Adapter changes an interface. Decorator keeps the interface and adds behaviour. Proxy keeps the interface and controls access. A designer who names the intent correctly communicates something real to the next reader of the code, even if the code is almost the same.
Idea seven: turning behaviour into objects
The behavioural patterns, the largest group, deal with algorithms and with how objects divide responsibility and communicate. Their common move is to take a piece of behaviour, a request, an algorithm, a state, a traversal, and make it into an object in its own right.
Command turns a request into an object. Once a request such as delete this paragraph is an object, it can be stored, queued, logged, sent elsewhere, and undone. Undo stacks in editors, job queues in servers and macro recorders all rest on this simple idea. Strategy turns an algorithm into an object, so that a sorting routine, a pricing rule or a compression method can be chosen at run time. State turns each condition of an object into a separate object, so that a network connection in the open state and the same connection in the closed state respond to requests through different classes rather than through long conditional statements. Iterator turns traversal into an object, so a collection can be walked without exposing its internals.
Communication patterns
Other behavioural patterns organise how objects talk. Observer lets one object notify many dependents without knowing who they are. Mediator centralises complex communication among a group of objects, like an air-traffic controller that prevents every plane from needing to talk to every other plane. Chain of Responsibility passes a request along a chain of possible handlers until one deals with it, as in a help system that asks the button, then its panel, then the window. Memento captures an object's internal state so it can be restored later without breaking encapsulation. Template Method defines the skeleton of an algorithm in a base class and lets subclasses fill in steps. Interpreter represents a small language's grammar as classes. Visitor lets new operations be added to a stable structure of classes without editing those classes.
The cost of indirection
Each of these patterns adds indirection. Behaviour that might have been a few lines in one method is now spread across several classes. For the person who knows the pattern, that spread is readable and purposeful. For the person who does not, it can feel like a maze. This is one of the central trade-offs of the book. Patterns make designs more flexible and, to the initiated, more communicative, but they raise the cost of entry. A team that uses them must share the vocabulary, or the benefit turns into confusion.
Idea eight: consequences are part of the pattern
A quiet but essential idea in the book is that every pattern has costs, and that the costs belong in its description. Each catalogue entry includes a section on consequences, and these sections are often the most valuable part. They explain what flexibility the pattern buys, what it makes harder, and what new problems it introduces.
For example, Visitor makes it easy to add new operations to a family of classes, but hard to add new classes to that family, because every visitor must then be updated. Observer decouples a subject from its observers, but it can produce cascades of unexpected updates and makes it hard to see, from reading the code, what will happen when something changes. Decorator gives flexibility, but a system built from many small wrappers can be hard to debug, because the object you are looking at is several layers deep. Flyweight saves memory, but it requires moving some state outside the objects and complicates the code.
Forces and judgement
The language of forces, borrowed from Alexander, captures this. A design problem is a balance of competing pressures: speed against flexibility, simplicity against extensibility, clarity against generality. A pattern resolves the forces in one particular way. Whether that resolution suits a given situation is a matter of judgement. The book cannot make that judgement for the reader, but by stating the consequences plainly it equips the reader to make it.
Why this is often missed
Popular retellings of the patterns frequently drop the consequences and keep only the diagram and a short code sample. That loses the most important part. A reader who learns Strategy as a diagram may use it everywhere. A reader who learns Strategy with its consequences, including the extra objects, the need for clients to know which strategy to choose, and the communication overhead between context and strategy, will use it where it pays. Going back to the original entries is the cure for pattern overuse.
Idea nine: patterns live in a language
The patterns in the book are written for statically typed, class-based languages of the early 1990s, chiefly C++ and Smalltalk. Many of them exist because those languages lacked certain features. This is not a flaw so much as a fact about what patterns are. A pattern is a solution that a community keeps rewriting by hand because its language does not provide it directly.
Consider Strategy and Command. In C++ of that era, passing a piece of behaviour to another object required defining a class with a method and creating an instance of it. In a language with first-class functions and closures, the same effect is achieved by passing a function. The idea of Strategy remains, the choice of algorithm is still separated from the code that uses it, but the scaffolding disappears. The same is true of Iterator in languages with built-in generators, of Observer in languages or frameworks with built-in event systems, and of Visitor in languages with pattern matching over data types.
Patterns move into languages and frameworks
Over the decades since the book appeared, many of its patterns have been absorbed. Iteration protocols are now standard in most mainstream languages. Event and listener systems, the practical form of Observer, are built into user-interface toolkits and browsers. Decorators appear as language syntax in some languages, though not always with exactly the book's meaning. Dependency injection frameworks handle much of what Abstract Factory and Factory Method once did by hand. Reactive programming libraries generalise Observer into streams of values. In each case the vocabulary survives even where the hand-written structure does not.
What this teaches
The lesson for a modern reader is twofold. First, do not mechanically translate the book's class structures into a language that offers a simpler way. A function is often the right Strategy. Second, do not dismiss the book because the scaffolding looks dated. The problems are the same: how to separate what changes from what stays, how to let parts communicate without knowing too much about each other, how to build large structures from small uniform pieces. Understanding the pattern lets a programmer recognise the same idea in a new language's built-in features and use them well.
Idea ten: patterns, toolkits and frameworks
The book distinguishes three levels of reuse, and the distinction clarifies what patterns are for. At the lowest level are toolkits: libraries of useful classes, such as collections or input and output routines, that an application calls when it needs them. At the highest level are frameworks: sets of cooperating classes that form the skeleton of a whole family of applications, such as a framework for drawing editors or for financial software. Patterns sit between these. They are smaller than frameworks and more abstract than toolkits.
Who calls whom
The key difference between a toolkit and a framework is the direction of control. With a toolkit, your code is in charge and calls the library. With a framework, the framework is in charge and calls your code at the points it has defined. This reversal is often called inversion of control, and it is visible every day: a web framework receives a request and calls your handler; a user-interface toolkit runs an event loop and calls your click handler; a test runner discovers your tests and calls them. The patterns are the joints that make this reversal possible. Template Method lets a framework define the steps of an algorithm and call your code for some of them. Factory Method lets a framework create objects whose exact class you choose. Observer lets a framework announce events to code it has never seen.
Why frameworks are hard
The authors note that frameworks are hard to design and hard to learn. A framework commits many design decisions in advance, and if those decisions are wrong, every application built on it suffers. A framework's users must also understand its internal architecture well enough to fit their code into it. The authors suggest that documenting a framework with the patterns it uses is one of the best ways to make it learnable. A newcomer who is told that a framework uses Composite for its views, Observer for its model and Strategy for its layout already understands most of its shape.
An illustration from testing
Gamma's later work on JUnit with Kent Beck is a small, clear case. The framework runs tests that users write; it uses Composite so that a single test and a suite of tests are treated alike; it uses Template Method so that every test has a set-up step, a body and a tear-down step in a fixed order; and it uses Command so that each test is an object that can be run, collected and reported on. Beck and Gamma later described JUnit's design explicitly as a series of pattern applications. Anyone who has used a testing framework in almost any language has used these ideas, whether or not they knew the names.
Where it leads
The insight that patterns are the building blocks of frameworks explains why the book's influence spread so widely. Most programmers today spend more time inside frameworks than writing their own from scratch. The frameworks they use, whether for web servers, mobile applications, games or data processing, were designed by people steeped in this vocabulary. Reading the book is therefore partly a way of reading the minds of framework designers, which makes the frameworks easier to use and easier to judge.
Reading the case study
The Lexi case study is the part of the book most often skipped and most worth reading. Its value lies in showing patterns in combination, under the pressure of a real design, rather than one at a time in isolation.
The editor must represent a document made of characters, images, rows and columns. It must format text into lines. It must allow embellishments such as borders and scroll bars. It must work on several window systems and with several visual styles. It must support user operations that can be undone. It must allow analyses of the text, such as spell checking and hyphenation, that walk over the whole document structure. Each of these requirements, examined carefully, pulls toward a particular pattern. The document's structure suggests Composite. The formatting algorithm suggests Strategy. The embellishments suggest Decorator. The multiple visual styles suggest Abstract Factory. The multiple window systems suggest Bridge. Undo suggests Command. Analysis over the structure suggests Iterator and Visitor.
What to notice
The reader should watch for three things. First, how a requirement is stated before any pattern is chosen; the patterns are responses to problems, not decorations. Second, how alternatives are considered and rejected, often because a naive approach would cause an explosion of classes or would tie two independent concerns together. Third, how the patterns fit together. The Composite structure of the document is what makes the Decorator embellishments and the Visitor analyses possible. Patterns rarely stand alone, and their value grows when they share a common structure.
A useful exercise is to take a system you know, perhaps a spreadsheet, a chat program or an online store, and ask the same questions of it. What is the core structure? What varies? What must be undoable? What must work across platforms? You will often find that the patterns appear without being sought.
Patterns as a way of reading code
Most discussions of the book treat patterns as tools for writing new code. In practice, their larger value may be as tools for reading code that someone else wrote. Programmers spend far more time reading than writing, and a large codebase is bewildering until its main structures become visible. Patterns are a set of shapes to look for.
Recognising shapes
When a reader meets a class that holds a list of listeners and loops over them when something changes, the word Observer makes the whole arrangement legible at once. When a reader sees an object that wraps another of the same type and forwards most calls, the question becomes whether it is a Decorator, a Proxy or an Adapter, and the answer reveals the author's intent. When a reader sees a family of small classes each implementing one method of a shared interface, Strategy or State is likely. This recognition turns hundreds of lines into a handful of design decisions.
Spotting misuse
The same knowledge reveals poor design. A factory that only ever produces one class, a visitor over a hierarchy that keeps gaining new classes, an observer chain so long that no one can predict the effects of a change, a singleton used to smuggle configuration into every corner of a program: each of these is a pattern applied against its own consequences. A reader who knows the original entries can name the problem and propose a remedy, often by removing the pattern rather than adding another.
An exercise
Take an open-source library you use often and read its main classes with the catalogue at hand. List every pattern you can identify, with the class names that play each role. Then ask, for each one, what variation it was meant to allow and whether that variation has actually happened. This exercise, done once or twice, teaches more about design than reading the catalogue several times over. It also builds respect for the designers whose choices hold up, and a clear eye for those whose do not.
Talking with others
Finally, patterns improve design discussions. In a review, saying that a proposed change turns a Strategy into a hidden State machine, or that a new feature would be cleaner as a Decorator than as another subclass, gives the conversation precise terms. Disagreements become about trade-offs rather than taste. This shared language is perhaps the book's most lasting gift, and it works only if the people using the words mean the same things by them, which is a good reason for a team to read the originals together.
The tradition around it
Before the book
The idea of patterns came from architecture. Christopher Alexander and his colleagues published A Pattern Language in 1977 and The Timeless Way of Building in 1979. Alexander described hundreds of patterns for towns, buildings and rooms, each with a problem, a context and a solution, linked into a network where larger patterns are completed by smaller ones. He hoped ordinary people could use such a language to design good places for themselves. Software designers who read Alexander in the 1980s saw an analogy with their own work. Kent Beck and Ward Cunningham's 1987 paper on pattern languages for user interfaces was an early result. Meanwhile, object-oriented practice had produced influential designs whose structure would later be named, especially the Model-View-Controller arrangement in Smalltalk, which the book's introduction discusses as a combination of several patterns.
Around the book
The book helped create a community. The Hillside Group was formed to promote patterns, and the Pattern Languages of Programs conferences began in the mid 1990s, where writers brought draft patterns to workshops for critique. A series of further catalogues followed. Pattern-Oriented Software Architecture, by Frank Buschmann and colleagues, appeared in 1996 and dealt with larger architectural patterns such as layers and pipes and filters. Martin Fowler's Patterns of Enterprise Application Architecture in 2002 described patterns for business software and databases. Enterprise Integration Patterns by Gregor Hohpe and Bobby Woolf in 2003 did the same for messaging between systems. Head First Design Patterns in 2004 retold the original catalogue in an informal style for a Java audience and introduced many programmers to the ideas.
In this bay
Several books on this shelf form a conversation with this one. Refactoring by Martin Fowler shows how a design can move toward a pattern in small safe steps, instead of being built with every pattern from the start; it is the natural partner to this book, and a later work by Joshua Kerievsky made that link explicit. Extreme Programming Explained by Kent Beck argues for simple design and introducing flexibility only when it is needed, a useful corrective to pattern enthusiasm. Domain-Driven Design by Eric Evans moves the focus from technical structures to the model of the business, but it uses patterns of its own and assumes the vocabulary of this book. Working Effectively with Legacy Code by Michael Feathers shows how to introduce seams, often interfaces and small objects, into code that has none; many of its techniques are patterns applied for testability.
Algorithms + Data Structures = Programs by Niklaus Wirth represents an earlier view of programming centred on data and procedures; reading it alongside this book shows how much the object-oriented focus on responsibilities changed the conversation. A Philosophy of Software Design by John Ousterhout offers a sharp counterweight: it argues for deep modules with simple interfaces and warns against many shallow classes, a criticism that applies to heavy-handed pattern use. Clean Code by Robert C. Martin and Code Complete by Steve McConnell both draw on pattern vocabulary in their advice. Designing Data-Intensive Applications by Martin Kleppmann shows how similar ideas of decoupling and notification reappear at the scale of whole distributed systems, in message queues and change streams.
Questions and criticisms
Patterns as a sign of missing language features
The most famous criticism came from Peter Norvig, who argued in a 1996 talk that most of the twenty-three patterns become invisible or much simpler in dynamic languages such as Lisp and Dylan. First-class functions, generic dispatch on several arguments and dynamic types make the class scaffolding unnecessary. Others extended the point to functional languages. The criticism is fair as far as it goes. It does not show that the design problems vanish, only that some languages solve them directly. The book itself says, in its introduction, that the choice of language influences which patterns are needed.
Overuse and pattern fever
A second criticism is practical. After the book became popular, many teams applied patterns indiscriminately, producing code with factories that create one kind of object, strategies with one implementation, and visitors over structures that never gain new operations. The result was more classes and more indirection with no gain in flexibility. Some interviews and courses treated knowing the patterns as a proxy for design skill, which encouraged this. The authors did not recommend such use, and the consequences sections warn against it, but the warning was often ignored.
Singleton and global state
Singleton has been singled out more than any other pattern. It offers a single instance with global access, which in practice often means a global variable. Global state makes dependencies hidden, ties tests together, and causes trouble in concurrent programs. Members of the original group themselves expressed second thoughts about it in later years. Many current designers prefer to create a single instance at the start of a program and pass it explicitly to whatever needs it.
Inheritance-heavy examples
Although the book argues for composition, several of its patterns, such as Template Method and Factory Method, rely on inheritance, and its diagrams are drawn in class terms. Readers coming from functional or data-oriented traditions sometimes find the whole approach too centred on classes. That is partly a matter of era. The sample code also uses C++ idioms that are no longer recommended, such as manual memory management with raw pointers. None of this undermines the ideas, but a modern reader should not copy the code literally.
Catalogue versus language
A subtler criticism comes from the patterns movement itself. Alexander's patterns form a language: each one points to larger patterns it helps complete and smaller patterns that complete it, so that a designer can move through them in order, from the town to the room. The book's catalogue has related-pattern links, but it is closer to a collection than to a true generative language. Some writers in the community argued that this made the patterns easier to misuse, because nothing in the catalogue says which pattern should come first or how a whole design grows. Alexander himself, invited to speak to software audiences in the 1990s, gently suggested that programmers had taken the form of his work more than its deeper aim, which was building things that are good to live in. For software, that aim would mean designs that are good for the people who maintain and use them, which is a higher bar than flexibility alone.
What has held up
A great deal has held up. The two principles of the introduction are as sound now as in 1994. The names are universal; an engineer anywhere can say observer, adapter or composite and be understood. The habit of describing a solution with its context and consequences, rather than as a bare technique, became the model for countless later catalogues, in software and beyond, including patterns for user-experience design, for organisations and for machine learning systems. And the core move of the behavioural patterns, turning actions and algorithms into first-class things that can be passed around, became mainstream as languages adopted closures and higher-order functions.
Why it is on this shelf
This shelf gathers books that teach durable ways of thinking. This one is here because it is a rare example of a field naming its own tacit knowledge. Before the book, good object-oriented design was largely a craft passed on by apprenticeship. After it, a large share of that craft had names, definitions and trade-offs that anyone could study.
For a reader who moves between Vedanta, Jyotish, science, economics and technology, the book offers something familiar. Every serious tradition builds a technical vocabulary that lets practitioners point precisely at recurring structures. A term in Sanskrit grammar, a yoga in a horoscope, a market structure in economics and a pattern in software design all do the same work. They compress a recurring configuration into a word, so that thought can move faster and more exactly. Seeing that function clearly in one field helps in all the others.
The book also teaches a discipline of trade-offs. Each pattern is offered with its costs. That habit, refusing to present any technique as free, is valuable well beyond programming. And the principle of composition over inheritance carries a general lesson about building systems: small parts with clear interfaces, combined freely, adapt better than rigid hierarchies.
Finally, it is here because it is still the reference. Frameworks, libraries and codebases, including the code that AI assistants now produce, use its names constantly. Knowing the original definitions makes it possible to read such code critically, to see when a pattern is used well and when it is only decoration.
How to read it
First pass
Begin with the introductory chapter and read it slowly, with a pencil. Mark each design principle and each cause of redesign. Write a short example of your own for each. This chapter can be read in two or three sittings and is worth more than any single pattern.
Then read the Lexi case study. Do not worry about the exact class diagrams. Follow the questions the authors ask and the reasons they give for rejecting simpler solutions. After each section, close the book and try to state in one sentence what problem the pattern solved.
The catalogue
Do not read the catalogue from front to back on a first pass. Start with the patterns you are most likely to meet: Strategy, Observer, Composite, Decorator, Adapter, Command, Factory Method and Iterator. For each one, read the intent, motivation, applicability and consequences carefully. Skim the structure diagram. Skip the sample code unless you read C++ or Smalltalk comfortably. Read the known uses to see where the pattern appeared in real systems.
On a second pass, read State, Template Method, Abstract Factory, Proxy, Facade and Chain of Responsibility. Leave Interpreter, Flyweight, Memento, Mediator, Bridge, Builder, Prototype, Visitor and Singleton for later or for when a problem calls for them. Visitor in particular is best read after you have met the problem it solves.
Pace and practice
Read one pattern per sitting. After each, write a small example in the language you use daily. Then write the same example without the pattern, using whatever the language offers directly, such as passing a function. Compare the two. This exercise teaches both the pattern and its limits. When you meet a pattern in a codebase you work on, return to its entry and read the consequences again; they will mean more with a real example in mind.
Pencil work
Three things deserve pencil work. The table in the introduction that maps causes of redesign to patterns. The consequences section of each pattern you study. And the related-patterns section, which, if you draw it as a map of arrows, shows the catalogue as a connected whole rather than a list.
What to read next
From this shelf, read Refactoring by Martin Fowler next, to learn how to move existing code toward or away from a pattern safely. Then A Philosophy of Software Design by John Ousterhout, for a sharp and different view of what makes a design simple. Domain-Driven Design by Eric Evans is the natural step for anyone designing business software. Extreme Programming Explained by Kent Beck gives the case for simple design and evolving flexibility. For a gentler retelling of the catalogue itself, outside this shelf, many readers find Head First Design Patterns a friendly first step before the original.
Questions to carry
- What problem in this code would the pattern I am about to use actually solve, and what would it cost?
- Which parts of this system are most likely to change, and are they isolated behind a stable interface?
- Where am I using inheritance only to reuse code, and would composition be simpler?
- Does my language offer a direct feature, such as a function or an event system, that makes this pattern unnecessary?
- If a new colleague read this code, would the pattern names help or confuse them?
- What is the intent of this wrapper: changing an interface, adding behaviour, or controlling access?
- Is there a uniform structure here, a part that looks like the whole, that Composite would make simpler?
- Which actions in this system need to be stored, queued or undone, and are they objects yet?
- How many places in the code must change when a new kind of product, shape or rule is added?
- Is this abstraction justified by a real second case, or only by a guess about the future?
- Where is global state hiding in this design, and how could it be passed explicitly instead?
- Which pattern did I recognise in a library this week, and did the library use it well?
- What recurring structure in my own work has no name yet, and how would I describe it as a pattern?
Words to know
- Design pattern: A named description of a recurring design problem, the core of a solution, and the consequences of applying it.
- Gang of Four: The common nickname for the four authors, and by extension for the book.
- Pattern language: Alexander's term for a network of related patterns that together guide design at several scales.
- Interface: The set of operations an object promises to support, independent of how they are carried out.
- Implementation: The concrete code and data that carry out an interface's operations.
- Composition: Building behaviour by having objects hold and use other objects.
- Inheritance: Defining a class as an extension of another class, reusing and overriding its behaviour.
- Delegation: An object handing a request to another object it holds, sometimes passing itself so the delegate can call back.
- Coupling: The degree to which one part of a system depends on the details of another.
- Creational pattern: A pattern concerned with how objects are created, so that clients do not depend on concrete classes.
- Structural pattern: A pattern concerned with how classes and objects are combined into larger structures.
- Behavioural pattern: A pattern concerned with algorithms and with how objects share responsibility and communicate.
- Class pattern and object pattern: Patterns that work mainly through inheritance fixed at compile time, versus through object relationships that can change at run time.
- Intent: The short statement in each catalogue entry of what the pattern does and what problem it addresses.
- Consequences: The benefits, costs and trade-offs of applying a pattern, described in each entry.
- Forces: The competing pressures in a design problem that a pattern balances.
- Known uses: Real systems in which a pattern was observed, cited as evidence that it is a pattern and not an invention.
- Framework: A reusable set of cooperating classes that defines the architecture of a family of applications.
- Double dispatch: Choosing which operation to run based on the types of two objects, the technique at the heart of Visitor.
- Model-View-Controller: A Smalltalk arrangement separating data, its presentation and user input, which the book analyses as several patterns working together.
- Lexi: The document editor used as the book's case study.
- Indirection: Adding a layer, such as an interface or a wrapper, between a caller and the code that does the work.
A note on this edition
This is a study edition written for this shelf in our own words. It explains the book's purpose, its central ideas, its background and its reception, and offers a plan for reading it. It does not reproduce the catalogue, the diagrams or the sample code, and it cannot replace them.
Design Patterns: Elements of Reusable Object-Oriented Software is in copyright and remains in print. It is worth getting from a library or a bookshop and keeping within reach, because it is the kind of book one returns to many times over a working life.