Skip to content
aipatterns.dev

Guide

Classification of Patterns

How the 22 classic design patterns are grouped by purpose into creational, structural and behavioral, plus other useful ways to slice them.

Also known as
Pattern categories

Three groups by purpose

The classic catalog sorts patterns by the kind of problem they solve. Ask what you are trying to control: object creation, object composition, or the flow of responsibility between objects.

Diagram source (Mermaid)
flowchart TD
  Q[What is the design problem about?] --> C[How objects get created]
  Q --> S[How objects fit together]
  Q --> B[How objects divide work and communicate]
  C --> CR[Creational]
  S --> ST[Structural]
  B --> BE[Behavioral]

Creational

Control how and when objects are created, so callers don't depend on concrete classes or construction details. See Creational patterns.

  • Factory Method: let a subclass or function decide which concrete product to create.
  • Abstract Factory: create families of related products that must match.
  • Builder: assemble a complex object step by step.
  • Prototype: create new objects by copying a configured instance.
  • Singleton: guarantee one instance with a global access point.

Structural

Compose classes and objects into larger structures while keeping them flexible. See Structural patterns.

  • Adapter: make one interface usable where another is expected.
  • Bridge: split an abstraction from its implementation so both vary.
  • Composite: treat trees of objects like single objects.
  • Decorator: add behavior by wrapping an object with the same interface.
  • Facade: give a simple front to a complex subsystem.
  • Flyweight: share common state across many small objects.
  • Proxy: stand in for another object to control access to it.

Behavioral

Assign responsibilities and define how objects communicate. See Behavioral patterns.

  • Chain of Responsibility: pass a request along handlers until one deals with it.
  • Command: turn a request into an object you can queue, log or undo.
  • Iterator: traverse a collection without exposing its structure.
  • Mediator: route communication through one coordinator.
  • Memento: capture and restore state without breaking encapsulation.
  • Observer: notify subscribers when something changes.
  • State: change behavior when internal state changes.
  • Strategy: swap interchangeable algorithms.
  • Template Method: fix an algorithm's skeleton and let steps vary.
  • Visitor: add operations over a structure without editing its classes.

A second axis: class vs object scope

The original catalog also asked whether a pattern works mainly through inheritance (class scope, fixed at compile time) or through composition (object scope, changeable at runtime).

ScopeMechanismExamples
ClassSubclassingFactory Method, Template Method, class-form Adapter
ObjectComposition and delegationStrategy, Decorator, Bridge, Observer, most others

Prefer object-scope patterns by default. They change at runtime, test more easily, and avoid deep hierarchies.

A third axis: how often you need them

Grouping by frequency is more useful day to day than grouping by purpose:

Each pattern page carries popularity and complexity scores (1 to 3) in its frontmatter for the same purpose.

Confusable neighbors across groups

Groups are not walls. Some patterns share a structure but differ in intent:

To pick among them from a symptom rather than a category, use Choosing a pattern.

See also

Original writing and examples. Topic coverage follows Refactoring.Guru, which explains this topic with its own illustrations.