Facebook Pixel

Patterns Overview

A design pattern is a named, reusable solution to a recurring design problem. It is not code to copy but a structure to adapt: a description of the classes and the way they collaborate. The catalog most interviews draw from is the Gang of Four (GoF) set — 23 patterns grouped into three categories by what they organize.

CategoryWhat it organizesPatterns
Creationalhow objects are createdFactory, Builder, Singleton, Prototype, Abstract Factory
Structuralhow objects are composed into larger structuresAdapter, Decorator, Composite, Facade, Proxy
Behavioralhow objects interact and divide responsibilityStrategy, Observer, State, Command, Template Method, Chain of Responsibility

Which patterns matter most

You do not need all 23. A small set accounts for most of what appears in low-level design interviews and in everyday code; the rest are specialized and are better learned when a concrete need arises. The table below groups the patterns this course covers by how often they come up in interviews, with the situation that signals each one.

PatternCategoryIn interviewsSignals you need it
StrategyBehavioralVery commona conditional selects between interchangeable algorithms
ObserverBehavioralVery commonmany parts must react to one event without the source knowing them
FactoryCreationalVery commonchoosing which concrete type to create from a tag or input
SingletonCreationalVery commonexactly one shared instance — though dependency injection is usually better
StateBehavioralCommonbehavior changes with a mode, and a status field is sprouting conditionals
BuilderCreationalCommonconstructing an object with many optional or validated parts
DecoratorStructuralCommonlayering optional behavior without subclass explosion
AdapterStructuralCommonbridging your interface to an incompatible or third-party one
CommandBehavioralCommonundo/redo, queuing, scheduling, or logging of actions
CompositeStructuralCommona part-whole tree treated uniformly (files, UI, org charts)
Template MethodBehavioralOccasionala fixed workflow whose individual steps vary
FacadeStructuralOccasionalone simple entry point over a complex subsystem
ProxyStructuralOccasionallazy loading, access control, or caching behind the same interface
Chain of ResponsibilityBehavioralOccasionala request passes along handlers until one takes it (middleware, approvals)
PrototypeCreationalOccasionalcloning a pre-configured object is cheaper or clearer than rebuilding it

Factory has two GoF variants worth naming — Factory Method and Abstract Factory — both covered in the Factory article.

What this section skips

Five GoF patterns are left out: Visitor, Mediator, Memento, Bridge, and Flyweight. They are rarely asked in interviews and tend to be reached for only in specific situations — large object structures with many operations (Visitor), heavy shared state to deduplicate (Flyweight), and so on. Recognizing the name and the problem each addresses is enough; the implementations are best learned when a real design calls for them.

How to use these patterns

Each article in this section follows the same shape: the problem the pattern solves, a before and after, and — just as important — when not to use it. Read them that way. The goal is not to memorize structures but to recognize the situation that calls for one.

The most common mistake is the opposite of forgetting a pattern: forcing one where a plain conditional or a single class would do. A pattern is worth its extra structure only when it removes a real, recurring cost — a branch edited again and again, a construction step duplicated, a dependency that should be swappable. When none of those is present, the simpler code is the better design. The Failure Modes article in Module 1 covers this pattern-forcing trap in detail.

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro