Web apps & software

What are software design patterns?

Design patterns are proven, named templates for solving problems that come up again and again in software design, such as creating objects flexibly, reacting to changes or swapping algorithms. They are ideas to adapt, not code to copy.

A few you will hear about

  • Strategy: interchangeable algorithms behind one interface. Example: a pricing engine that picks flat-rate, metered or zone pricing per customer.
  • Observer: objects subscribe to changes in another object; the basis of most UI event systems.
  • Factory: one place decides which concrete class to create, so callers do not need to know.
  • Adapter: wraps an awkward third-party API so the rest of your code sees a clean interface.
  • Repository: hides how data is stored behind methods like findById and save.

Why they matter beyond code

Patterns give developers a shared shorthand. "Put an adapter around the old SMS gateway" communicates a whole design in five words. In code reviews and estimates, that vocabulary speeds up discussion.

The common misuse

Applying patterns because they exist rather than because a problem needs them. A simple script wrapped in factories and abstract classes becomes harder to read with no benefit. Good developers reach for a pattern when they feel the specific pain it solves. The classic catalogue is the 1994 "Gang of Four" book, but many modern patterns, such as circuit breaker or saga, come from distributed systems.

Questions, answered

Mostly not, though some become unnecessary in languages with built-in features such as first-class functions.

A common approach that looks reasonable but usually causes problems, such as a god class that does everything.

By the Stegnor team · Updated