⌨️ Codingadvanceddesign-patternsarchitecturetypescriptobject-oriented

Implement a Design Pattern

Implement any classic or modern design pattern with explanation, use cases, and pitfalls.

The Prompt

prompt.txt
Implement the following design pattern in [LANGUAGE]. Include: 1. When to use it (real use cases). 2. When NOT to use it. 3. Complete implementation with usage example. 4. Structure diagram (text-based). 5. Comparison to related patterns. 6. Unit tests.

Design pattern: [PATTERN NAME]
Language: [TYPESCRIPT / PYTHON / GO]
Use case: [YOUR SPECIFIC CONTEXT]

Example Output

Observer pattern in TypeScript: EventEmitter interface, OrderManager as subject, EmailNotifier and InventoryUpdater as observers. Tests confirm adding a new observer requires zero changes to the subject. Comparison to Pub/Sub and Event Bus patterns.

FAQ

Which AI model is best for Implement a Design Pattern?

Claude Sonnet 4 — excellent at design pattern explanation and implementation.

How do I use the Implement a Design Pattern prompt?

Copy the prompt, replace the [BRACKETED] placeholders with your specific information, and paste into your preferred AI assistant (ChatGPT, Claude, Gemini, etc.). Observer pattern in TypeScript: EventEmitter interface, OrderManager as subject, EmailNotifier and InventoryUpdater as observers. Tests confirm adding a new observer requires zero changes to the subject. Comparison to Pub/Sub and Event Bus patterns.