Prompt Library ⚙️ Technical Implement a Design Pattern in Your Codebase
GPT-4o ⚙️ Technical Intermediate

Implement a Design Pattern in Your Codebase

Learn and apply a specific software design pattern to your real codebase — with explanation, trade-offs, and complete implementation code.

👁 5 views ⎘ 0 copies ♥ 0 likes

The Prompt

# Implement a Design Pattern in Your Codebase

You are a senior engineer teaching design patterns through practical implementation.

## Context

Pattern to implement: [DESIGN_PATTERN] (Observer, Factory, Strategy, Repository, etc.)
Language: [LANGUAGE]
My codebase context: [CODEBASE_DESCRIPTION]
Problem I'm trying to solve: [PROBLEM_DESCRIPTION]

## Pattern Explanation

**What is [DESIGN_PATTERN]?**
Explain in plain terms what problem this pattern solves and when to use it vs. when not to.

**Is this the right pattern for [PROBLEM_DESCRIPTION]?**
Give an honest assessment. If a simpler approach exists, say so.

**Trade-offs:**
- Advantages for [CODEBASE_DESCRIPTION]
- Disadvantages and complexity costs
- Alternatives to consider

## Implementation

Write a complete [DESIGN_PATTERN] implementation in [LANGUAGE] for [PROBLEM_DESCRIPTION]:

```[LANGUAGE]
[COMPLETE_IMPLEMENTATION]
```

Include:
- Core pattern classes/interfaces
- A concrete usage example from [CODEBASE_DESCRIPTION]
- Unit tests demonstrating the pattern works

## Integration Steps

Walk through how to add this implementation to [CODEBASE_DESCRIPTION] without breaking existing code:
1. What to add
2. What existing code to modify
3. What to test after integration

## When to Extend

How would this implementation need to change if [FUTURE_REQUIREMENT]?

📝 Fill in the blanks

Replace these placeholders with your own content:

[DESIGN_PATTERN]
[LANGUAGE]
[CODEBASE_DESCRIPTION]
[PROBLEM_DESCRIPTION]
[COMPLETE_IMPLEMENTATION]
[FUTURE_REQUIREMENT]

How to use this prompt

1
Copy the prompt

Click "Copy Prompt" above to copy the full prompt text to your clipboard.

2
Replace the placeholders

Swap out anything in [BRACKETS] with your specific details.

3
Paste into GPT-4o

Open your preferred AI assistant and paste the prompt to get started.