| Abstract Factory | Creational | A factory of factories. Creates families of related objects. | Swapping entire cloud SDKs (e.g., an AWS Factory creating SQS/S3 vs. a Local Factory creating Kafka/MinIO). |
| Singleton | Creational | Ensures only one instance of a class exists. | The default behavior of a Spring Bean. |
| Prototype | Creational | Clones an existing object instead of building from scratch. | Using @Scope("prototype") in Spring for stateful, non-shared components. |
| Bridge | Structural | Separates an interface from its implementation so both can vary independently. | Your service layer interface (Abstraction) talking to different database drivers (Implementation). |
| Composite | Structural | Treats a group of objects the exact same way as a single object (Tree structure). | Parsing JSON/XML structures, or representing a hierarchical file system. |
| Flyweight | Structural | Shares massive amounts of fine-grained data to save RAM. | The Java String pool, or caching standard AWS Region configurations across millions of requests. |
| Chain of Responsibility | Behavioral | Passes a request along a chain of handlers until one handles it. | Spring Security Filter Chain (Checking CORS, then Auth, then Roles). |
| Command | Behavioral | Turns a request into a standalone object containing all info about it. | Sending tasks to an AWS SQS queue or a Kafka topic to be executed asynchronously. |
| Iterator | Behavioral | Lets you traverse a collection without exposing its underlying representation. | Using List.iterator() or Stream API to loop through database query results. |
| Memento | Behavioral | Captures and restores an object’s internal state (Undo mechanism). | Implementing rollback features in distributed transactions (Saga pattern). |
| Template Method | Behavioral | Defines the skeleton of an algorithm in a base class, letting subclasses override specific steps. | Spring’s JdbcTemplate or RestTemplate. |
| Visitor | Behavioral | Separates an algorithm from the object structure on which it operates. | Exporting a massive graph of distinct microservice logs into a single unified JSON report. |