← Back to Roadmap

Design Patterns Introduction

Medium

In plain terms

Design patterns are typical solutions to recurring design problems. They are not ready-made code you copy—they are templates you adapt. Examples: Singleton (one instance), Factory (create objects without specifying exact class), Observer (notify dependents of changes).

Patterns give you a common language ("we use a Repository pattern here") and help you avoid reinventing the wheel. Do not force a pattern where the problem does not fit; use them when they simplify design. Learning a few core patterns (Factory, Strategy, Observer, Decorator) goes a long way.

What you need to know

  • Reusable solutions to common problems
  • Template to adapt, not copy
  • Shared vocabulary

Example

Code is language-agnostic in spirit; adapt the idea to your language:

// Observer: subject notifies listeners
class Subject {
  constructor() { this.listeners = []; }
  subscribe(fn) { this.listeners.push(fn); }
  notify(data) { this.listeners.forEach(fn => fn(data)); }
}
// When state changes, call notify() - all subscribers run

Why this matters

Design patterns are a common interview topic. You do not need to memorize all; knowing a few (Singleton, Factory, Observer, Strategy) and when they apply is enough.

How it connects

Patterns often implement SOLID: Factory supports DIP/OCP; Observer uses interfaces (ISP). They give you a vocabulary to discuss design and to recognize when a problem matches a known solution.

Interview focus

Be ready to explain these; they come up often.

  • Patterns are reusable solutions to recurring problems; templates to adapt, not copy.
  • Know at least: Singleton, Factory, Observer, Strategy—and when to use each.
  • Do not force a pattern; use when it simplifies design and communication.

Learn more

Dive deeper with these resources: