Loading...
Loading...
Gang of Four design patterns reference. Use this skill when implementing, discussing, or choosing object-oriented design patterns. Auto-activates for architecture decisions, refactoring, and decoupling concerns. Comprehensive coverage of all 23 GoF patterns with pseudocode examples.
npx skill4agent add grndlvl/software-patterns gof-patterns| Pattern | Intent | Use When |
|---|---|---|
| Abstract Factory | Create families of related objects | Need platform/theme independence |
| Builder | Construct complex objects step-by-step | Object has many optional parts |
| Factory Method | Let subclasses decide which class to instantiate | Don't know concrete types ahead of time |
| Prototype | Clone existing objects | Object creation is expensive |
| Singleton | Ensure single instance | Need exactly one shared instance |
| Pattern | Intent | Use When |
|---|---|---|
| Adapter | Convert interface to expected interface | Integrating incompatible interfaces |
| Bridge | Separate abstraction from implementation | Need to vary both independently |
| Composite | Treat individual and groups uniformly | Have tree structures |
| Decorator | Add responsibilities dynamically | Need flexible extension |
| Facade | Simplified interface to subsystem | Complex subsystem needs simple API |
| Flyweight | Share common state efficiently | Many similar objects needed |
| Proxy | Control access to object | Need lazy loading, access control, logging |
| Pattern | Intent | Use When |
|---|---|---|
| Chain of Responsibility | Pass request along handler chain | Multiple handlers, unknown which handles |
| Command | Encapsulate request as object | Need undo, queue, or log operations |
| Interpreter | Define grammar and interpret sentences | Have a simple language to parse |
| Iterator | Sequential access without exposing internals | Need to traverse collections |
| Mediator | Centralize complex communications | Many objects communicate in complex ways |
| Memento | Capture and restore object state | Need undo/snapshot functionality |
| Observer | Notify dependents of state changes | One-to-many dependency |
| State | Alter behavior when state changes | Object behavior depends on state |
| Strategy | Encapsulate interchangeable algorithms | Need to swap algorithms at runtime |
| Template Method | Define skeleton, let subclasses fill in | Algorithm structure fixed, steps vary |
| Visitor | Add operations without changing classes | Need to add many operations to stable structure |
classfunction->//name: Typeclassfunction->//classfunction.//classdef.#new