Skip to content

All Patterns

46 production-proven patterns organized by category. Each one has interactive visualization, multi-language implementations, exercises, and precise source links.

Data Structures

PatternOne-LinerSources
BitmaskPack N flags into one integer, O(1) test any comboReact, Linux
Min HeapO(1) peek at highest priority, O(log n) push/popReact, Linux CFS
Ring BufferFixed-size FIFO, wraps around, zero allocationLMAX, Linux
TrieO(k) prefix lookup, shared prefixes share nodesLinux FIB, Redis
Skip ListProbabilistic O(log n) sorted structureRedis, LevelDB
Bloom FilterProbabilistic set membership, zero false negativesLevelDB, Chromium
LRU CacheEvict least recently used, O(1) get/putgroupcache, Linux
B+ TreeHigh-branching tree, leaf-linked for range scansPostgreSQL, SQLite
Tagged UnionType tag + union for safe multi-type dispatchGodot, PyTorch
Merkle TreeHash upward for O(log n) integrity proofGit, ZFS
Merge IteratorK-way merge via min-heapLevelDB, RocksDB

Concurrency

PatternOne-LinerSources
SemaphoreCounter limits concurrent accessLinux, Go
Actor ModelPrivate state + mailbox, no shared memoryAkka, Erlang
Work StealingIdle threads steal from busy queuesGo, Tokio
MVCCVersioned rows let readers never block writersPostgreSQL, etcd
Cooperative SchedulingYield between work chunks to stay responsiveReact, Go
Double BufferingSwap two copies for atomic updateReact Fiber, GPU
BackpressureSlow producer when consumer can't keep upNode.js, Reactive
Event LoopSingle-threaded I/O multiplexinglibuv, Redis
Logical ClockOrder events without wall-clock timeetcd, LevelDB

System

PatternOne-LinerSources
Circuit BreakerStop calling failing services, fail fastHystrix, gobreaker
Rate LimiterToken bucket controls throughputGo, Nginx
Retry with BackoffExponential delay + jitter on failureK8s, gRPC
Write-Ahead LogLog changes before applying, crash-safeetcd, PostgreSQL
Batch ProcessingAccumulate ops, execute as groupKafka, React
Consistent HashingAdd/remove nodes remaps ~1/n keysgroupcache, HAProxy
Dependency GraphDAG + topological sortCargo, pnpm
Middleware ChainComposable pre/post handlersgRPC, Koa
RegistrySelf-register by name, discover at runtimeTensorFlow, gRPC
Dirty FlagRecompute only when marked changedChromium, React
LSM TreeBuffer writes in memory, flush sorted to diskLevelDB, RocksDB
CheckpointingPeriodic snapshot, recover from checkpointPostgreSQL, Redis

Memory

PatternOne-LinerSources
Object PoolPre-allocate and reuse to skip GCGo sync.Pool, Godot
FlyweightShare identical immutable objectsPython int cache, V8
Arena AllocatorBump-allocate in region, free all at oncebumpalo, Go
Free ListO(1) alloc/free via linked freed slotsGo runtime, Linux
Copy-on-WriteShare by reference, copy on mutationGit, Rust Cow
Reference CountingAuto-cleanup at zero ownersCPython, Rust Arc
TombstoneMark deleted, reclaim laterLevelDB, Cassandra
InterningDeduplicate immutable values, pointer equalityRust compiler, CPython

Behavioral

PatternOne-LinerSources
State MachineExplicit states, impossible transitions unrepresentableXState, Linux TCP
ObserverSubscribe to events, decouple producer/consumerEventEmitter, Redux
IteratorLazy sequences, zero intermediate allocationsRust, Python
Diff / PatchCompute minimal changes between two statesReact, Git
VtableFunction pointer struct for polymorphismLinux kernel, CPython
VisitorDispatch type-specific callbacks on tree nodesLLVM, Vue

Released under the MIT License.