Design Patterns
Flyweight Pattern
Sometimes the problem isn’t CPU — it’s memory. You have thousands or millions of tiny objects that mostly look the same, and your heap starts to complain. The Flyweight pattern is …
Facade Pattern
You may have used a library that feels like “call this one function and everything just happens”. Behind that one function, there’s usually a lot of orchestration. The Facade …
Decorator Pattern
Think of adding toppings to a pizza or filters to a photo: you start with something simple, then wrap it with extra behavior. You don’t need a new “class” of pizza for every …
Composite Pattern
Files and folders. Menu items and submenus. Shapes and groups of shapes. We constantly work with part–whole hierarchies, and we’d really like to treat “a single item” and “a group …
Bridge Pattern
Sometimes your class hierarchy starts to explode: circles vs squares, vector vs raster, light theme vs dark theme… and suddenly you’re staring at a grid of combinations. The Bridge …
Adapter Pattern
We run into adapters in real life all the time: power‑plug adapters, HDMI–to–USB‑C dongles, language interpreters. Software has the same problem — two sides that need to talk, but …
Proxy Pattern
Any time you click something and it looks like the real object, but behind the scenes there’s access control, caching, logging, or lazy loading happening — that’s the Proxy pattern …
Visitor Pattern
Every time you think “I need to run a bunch of different operations over this object hierarchy, but I really don’t want to keep changing those classes”, you’re in Visitor …
Template Method Pattern
If you’ve ever created a base class with a run() method that calls a series of steps, then let subclasses override only a few of those steps, you’ve already reinvented the Template …
Strategy Pattern
Any time you choose between “pay with card”, “pay with PayPal”, or “pay with bank transfer”, you’re bumping into the idea behind the Strategy pattern. Strategy is a behavioral …