Design Patterns
Gang of Four patterns with real-world context, code examples in Swift, Kotlin, TypeScript, Python & Java, and practical use cases for every scenario.
Creational
Control how objects are createdEnsures a class has only one instance and provides a global access point to it.
Defines an interface for creating objects but lets subclasses or a factory function decide which class to instantiate.
Constructs complex objects step by step using a fluent interface, separating construction from representation.
Creates new objects by cloning an existing instance rather than constructing from scratch.
Structural
Define how objects are composedWraps an incompatible interface so it can work with existing code without modification.
Wraps an object to add new behavior dynamically, without subclassing.
Provides a simplified interface to a complex subsystem, hiding its internals.
Provides a placeholder that controls access to another object — adding lazy loading, caching, or access checks.
Composes objects into tree structures and lets clients treat individual objects and compositions uniformly.
Behavioral
Define how objects communicateDefines a one-to-many dependency so that when one object changes state, all its dependents are notified automatically.
Defines a family of interchangeable algorithms and lets you swap them at runtime.
Encapsulates a request as an object, enabling undo/redo, queuing, and logging of operations.
Allows an object to change its behavior when its internal state changes — appears to change class.
Passes a request along a chain of handlers; each handler decides whether to handle it or forward it.
Defines the skeleton of an algorithm in a base class, deferring specific steps to subclasses.
Provides a way to sequentially access elements of a collection without exposing its underlying representation.