Skip to the workspace
Pebellslearn by building
Design Patterns  ›  Lesson

What Design Patterns Are

GoF Design Patterns 13 minA design pattern is a named, reusable solution shape for a recurring design problem, catalogued as creational, structural or behavioural.

software design architecture / What Design Patterns Are

Explore each scene at your own pace.

01 · The rule

The rule

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.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.