Skip to main content

Design Pattern

In Turkish
Tasarım Deseni
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/design-pattern

In short

A design pattern is a proven, reusable solution to a common problem in software design, described as a general template rather than as finished code.

What is a design pattern?

A design pattern is a named, well-tested way of structuring code to solve a problem that comes up again and again. It is not a library or a snippet you copy; it is a description of the idea, the parts involved, and the trade-offs. Shared names like Singleton or Observer also let developers describe a whole design in a single word.

The classic patterns were popularized by the 1994 book Design Patterns, whose four authors are known as the Gang of Four, and are grouped into three families. Creational patterns, such as Factory and Builder, deal with how objects are created. Structural patterns, such as Adapter and Decorator, deal with how objects are combined, and behavioral patterns, such as Observer and Strategy, deal with how objects communicate.

An everyday analogy is a proven kitchen layout: every kitchen is different, but the tried-and-tested arrangement of sink, stove, and fridge can be reused again and again. Patterns also exist beyond classes and objects, for example in front-end frameworks, distributed systems, and at the application level with architectural patterns like MVC.

A design pattern is different from an algorithm. An algorithm is a precise sequence of steps that computes a result, while a pattern is a flexible way of organizing code. Using a pattern where it isn't needed adds complexity, so patterns should solve a real problem rather than be applied for their own sake.

At a glance

A design pattern is a named, reusable answer to a common design problem. In the Observer pattern shown here, an order service keeps a list of subscribers and, when an order is placed, notifies each one through the same interface without knowing what any of them does.Problem: many parts must react to one event, without the sender knowing them.callsOrderServicesubscribers: […]placeOrder()→ notify eachSubscriberonOrderPlaced(order)EmailSenderimplements SubscriberInvoiceMakerimplements SubscriberAnalyticsimplements SubscriberPattern: Observer
Observer is one of many: Factory, Adapter, Strategy and Singleton each name a shape that solves another problem that keeps coming up.

Key takeaways

  • A design pattern is a reusable solution template, not ready-made code.
  • Classic patterns are creational, structural, or behavioral.
  • Pattern names give developers a shared vocabulary.
  • Overusing patterns can make simple code needlessly complex.

Example

The Strategy pattern in TypeScripttypescript
// Strategy: swap an algorithm without changing the code that uses it
interface ShippingStrategy {
  cost(weightKg: number): number;
}

const standard: ShippingStrategy = { cost: (kg) => 5 + kg };
const express: ShippingStrategy = { cost: (kg) => 15 + kg * 2 };

function checkout(weightKg: number, shipping: ShippingStrategy) {
  return shipping.cost(weightKg);
}

console.log(checkout(3, standard)); // 8
console.log(checkout(3, express));  // 21

Readers ask

What are the most common design patterns?

Frequently used patterns include Singleton, Factory, Builder, Adapter, Decorator, Observer, and Strategy. Many are built into modern languages and frameworks, so you often use them without noticing; event listeners, for example, follow the Observer pattern.

Are design patterns still relevant today?

Yes. Modern language features have made some patterns simpler or unnecessary, but the underlying ideas and the shared vocabulary are still widely used in codebases, frameworks, and technical interviews.

What is the difference between a design pattern and an architectural pattern?

A design pattern solves a problem inside one part of a codebase, such as how a few classes work together. An architectural pattern, such as MVC or microservices, shapes the structure of an entire application or system.

See also

Free · once a week

Software and AI, explained once a week

The week's software and AI news with every term explained, plus a term to learn and a quick quiz. A two-minute read.

You confirm by email first, and one click unsubscribes. Privacy

See this week's issue

About this page

Page history

  1. Added a diagram: the Observer pattern as a worked example.

Changes that altered what this page says. Typo fixes are not listed.

Spotted a mistake or something missing on this page?Suggest an edit

How pages are made

More

Settings