Design patterns (GoF)
The 23 classic object-oriented patterns from the Gang of Four, each with a class diagram, a sequence diagram and a TypeScript example.
Creational
How objects get made, without hard-wiring which class you get.
Create whole families of related objects through one interface, so code never mixes parts from different families.
Assemble a complex object step by step with readable calls, check the rules once at the end, and get back a finished, valid object.
Let a base class run a workflow but leave one step, creating an object, to subclasses that decide which class it is.
Create new objects by copying a configured example, instead of building each one from scratch.
Make sure a class has exactly one instance and give the whole program one way to reach it. Useful, and the most overused pattern.
Structural
How objects and classes fit together into larger structures.
Wrap an existing class whose interface doesn't fit, so it works with code that expects a different interface.
Split something that varies in two ways into two separate class hierarchies, joined by a reference, so each side can grow on its own.
Build tree structures where single items and groups share one interface, so code can treat a whole group exactly like one item.
Wrap an object in another object with the same interface to add behaviour, such as caching, logging or retries, without changing the original.
Give a complicated subsystem one simple front door, so most callers can use it without knowing how its parts fit together.
Share the common, unchanging part of many similar objects instead of copying it into each one, to save memory at scale.
Put a stand-in with the same interface in front of an object to control access to it: check permissions, create it lazily, or reach it remotely.
Behavioral
How objects talk to each other and share responsibility.
Pass a request along a chain of handlers; each one either handles it or hands it to the next, so the sender doesn't need to know who deals with it.
Turn a request into an object with everything needed to run it, so you can queue it, log it, retry it or undo it.
Represent each rule of a small language as a class, build sentences as trees of those objects, and evaluate the tree to get an answer.
Walk through the items of a collection one at a time without exposing how the collection is stored, whether it's an array, a tree or a paginated API.
Make objects talk through one coordinator instead of directly to each other, so the rules about who affects whom live in one place.
Capture an object's state in a snapshot so you can restore it later, without exposing the object's internals to whoever keeps the snapshots.
Let objects subscribe to another object's changes, so it can notify all of them without knowing who they are.
Let an object change its behaviour when its internal state changes, with one class per state instead of status checks in every method.
Put each variant of an algorithm in its own class behind one interface, so callers can swap behaviour without changing their code.
Write the skeleton of an algorithm once in a base class, and let subclasses fill in only the steps that differ.
Add new operations to a fixed set of classes without changing them, by putting each operation in its own visitor object.