A collection of design patterns and idioms in Python.
Creational Patterns:
| Pattern | Description |
|---|---|
| Abstract Factory | use a generic function with specific factories |
| Builder | instead of using multiple constructors, builder receives parameters and returns constructed objects |
| Factory Method | delegate a specialized function/method to create instances |
| Prototype | use a factory and clones of a prototype for new instances (if instantiation is expensive) |
| Singleton | Ensures that the class has only one instance, and provides a global access point to it. |
Structural Patterns:
| Pattern | Description |
|---|---|
| Adapter | converts the interface of one class to the interface of another that clients expect. |
| Bridge | a client-provider middleman to soften interface changes |
| Composite | lets clients treat individual objects and compositions uniformly |
| Decorator | wrap functionality with other functionality in order to affect outputs |
| Facade | use one class as an API to a number of others |
| Flyweight | transparently reuse existing instances of objects with similar/identical state |
| Proxy | an object funnels operations to something else |
Behavior Patterns:
| Pattern | Description |
|---|---|
| Blackboard | architectural model, assemble different sub-system knowledge to build a solution, AI approach - non gang of four pattern. |
| Chain Of Responsibility | apply a chain of successive handlers to try and process the data. |
| Command | bundle a command and arguments to call later. |
| Interpreter | a behavioral design pattern that solves a frequently encountered but subject to change problem. |
| Iterator | traverse a container and access the container's elements. |
| Mediator | an object that knows how to connect other objects and act as a proxy. |
| Memento | generate an opaque token that can be used to go back to a previous state. |
| Observer | provide a callback for notification of events/changes to data. |
| State | logic is organized into a discrete number of potential states and the next state that can be transitioned to. |
| Strategy | selectable operations over the same data. |
| Template Method | defines the basis of the algorithm and allows subclasses to override some of the steps in the algorithm, without changing its structure as a whole. |
| Visitor | invoke a callback for all items of a collection. |
By using this software, you agree to the full disclaimer terms.
Summary: Software provided "AS IS" without warranty. You assume all risks.
Full legal disclaimer: See DISCLAIMER.md
Licensed under BSD 3-Clause License • Copyright (©) 2026, Alexander Suvorov