Design patterns you'll actually use in 2025
Share
TL;DR: Reach for patterns when the structure repeats. Strategy, Observer, and Factory solve common problems without ceremony when used with modern JavaScript and TypeScript.
Strategy
Select behavior at runtime without if ladders.
type PriceRule = (amount: number) => number;
const student: PriceRule = a => a * 0.8;
const vip: PriceRule = a => a * 0.7;
function checkout(amount: number, rule: PriceRule) {
return rule(amount);
}
Observer
Notify subscribers when state changes.
class Bus {
private subs = new Set<(msg: string)>();
on(fn: (msg: string) => void) { this.subs.add(fn); }
off(fn: (msg: string) => void) { this.subs.delete(fn); }
emit(msg: string) { this.subs.forEach(fn => fn(msg)); }
}
Factory
Create objects with consistent setup.
function makeLogger(context: string) {
return (msg: string) => console.log(`[${context}] ${msg}`);
}
When not to use patterns
- One-off logic with no repetition
- When a simple function is clearer
FAQ
Do I need classes
No. Functions and simple objects often implement patterns cleanly in modern JS and TS.
Are patterns outdated in functional programming
The problems remain. The implementations change. Use the simplest tool for the job.
Cast this in your project
- Design Patterns Flashcards for fast refreshers.
- Vibe Coding Bible - Ebook for modern architecture with AI.
Image credit: Photo by Scott Webb: https://www.pexels.com/photo/purple-and-blue-abstract-wallpaper-430207/