Computer ScienceProgrammingMedium

Design Pattern

Also known as:software patternarchitectural pattern (broadly)GoF pattern

A design pattern is a reusable, named solution to a commonly occurring problem in software design, described at a level of abstraction independent of any particular programming language. Design patterns capture proven architectural knowledge and improve communication between developers by providing a shared vocabulary. Popularised by the "Gang of Four" (Gamma, Helm, Johnson, Vlissides) in their 1994 book, patterns are categorised as creational, structural, or behavioural based on their intent.

Gang of Four Design Patterns by Category

CategoryPattern NameIntentExample Use Case
CreationalSingletonEnsure only one instance existsDatabase connection pool
CreationalFactory MethodDelegate instantiation to subclassesUI widget creation
StructuralAdapterConvert interface to anotherLegacy API wrapping
StructuralDecoratorAdd behaviour without subclassingMiddleware pipelines
BehaviouralObserverNotify dependents of state changesEvent listeners, MVC
BehaviouralStrategyEncapsulate interchangeable algorithmsSorting, payment gateways

Interactive Tools

Refactoring.Guru – Design Patterns

Open Tool

Codecademy – Software Design Patterns

Open Tool

Brilliant – Software Engineering

Open Tool
UML class diagram illustrating the Observer design pattern

Wikimedia Commons, CC BY-SA

Related Terms

The concept was adapted from architect Christopher Alexander's "pattern language" (1977). Erich Gamma and colleagues applied it to software in "Design Patterns: Elements of Reusable Object-Oriented Software" (1994), cementing the term in computer science.

design-patternoopsoftware-engineeringgang-of-fourarchitecturereusability