Definition
A design pattern is a named, reusable solution to a problem that recurs across many designs. It is not finished code you can paste in — it is a description of how a set of classes and objects collaborate to solve the problem, written generally enough that you adapt the arrangement to your own situation each time you apply it.
Every design pattern records four essential elements. The name gives the pattern a handle, expanding the vocabulary designers use to talk to one another. The problem states when to apply the pattern — the context and conditions that must hold. The solution describes the participating classes, their responsibilities, and how they collaborate, as an abstract template rather than a concrete implementation. The consequences spell out the trade-offs: what the pattern costs in flexibility, performance, or complexity, so you can weigh it against alternatives.
Why it matters
How it works
The catalog and its three families
The classic catalog organizes patterns by purpose into three families. Creational patterns abstract how objects are instantiated, so a system stays independent of how its parts are created. Structural patterns compose classes and objects into larger structures while keeping those structures flexible. Behavioral patterns describe how objects distribute responsibility and communicate, capturing the flow of control between collaborators. Each entry in the catalog is indexed by name, intent, and the problem it addresses, so you locate the right pattern by the problem you face, not by the code you want.
Two principles that recur
Most patterns lean on the same underlying advice. Program to an interface, not an implementation means clients depend on an abstract type, so any conforming object can be substituted without the client knowing. Favor object composition over class inheritance means assembling behavior from collaborating objects at run time rather than freezing it into a class hierarchy at compile time. Patterns are, in large part, disciplined ways of encapsulating what varies behind these stable abstractions.