What Design Patterns Are
In a Shelfwise design meeting, one developer spends five minutes describing "an object that holds a list of other objects and calls each of them when something happens, without knowing what they are". Another says: "So, an Observer?" Everyone nods. That one word carried the whole design. That is the first gift of design patterns: a shared vocabulary for solutions that keep coming back.
The rule
A pattern is a named solution shape for a problem that keeps recurring.
A design pattern is not a library and not code to paste. It is a description of a problem that shows up again and again, plus the shape of a solution that has worked many times. You adapt the shape to your own code.
Each pattern is usually written up with:
- a name (Strategy, Observer, Decorator),
- the problem it solves and when it applies,
- the structure of the solution (which roles, how they connect),
- the consequences: what you gain and what it costs.
The best-known catalogue comes from a 1994 book by four authors, nicknamed the Gang of Four (GoF). It describes 23 object-oriented patterns in three families:
- Creational: how objects get made. Factory Method, Builder, Singleton.
- Structural: how objects are put together. Adapter, Decorator, Composite.
- Behavioural: how objects share work and talk. Strategy, Observer, Command.
A later series, Pattern-Oriented Software Architecture (PoSA), catalogues larger-scale patterns such as layers, pipes and filters, and brokers. Those shape whole systems rather than a few classes, and belong to the architecture stage of your learning.
Notice how much of the previous section reappears. Most patterns are the design principles applied to a specific problem: encapsulate what varies, program against abstractions, prefer composition.