Prompt Library › ⚙️ Technical › Implement Design Patterns with AI
GPT-4o ⚙️ Technical Advanced

Implement Design Patterns with AI

Apply [DESIGN_PATTERN] to [EXISTING_CODE] — get a refactored implementation with a before/after comparison and explanation of the trade-offs.

👁 4 views ⎘ 0 copies ♥ 0 likes

The Prompt

# Implement Design Patterns with AI

You are a software architect. Refactor [EXISTING_MODULE] by applying the [DESIGN_PATTERN] pattern in [LANGUAGE].

## Current Implementation

```
[PASTE_CURRENT_CODE_HERE]
```

## Why This Pattern

Explain why [DESIGN_PATTERN] is the right fit for this code given:
- The current problem: [CURRENT_PROBLEM]
- The change pressure: [EXPECTED_CHANGE]
- The team context: [TEAM_CONTEXT]

## Refactored Implementation

Provide the full refactored code implementing [DESIGN_PATTERN]. Highlight:
- The new abstractions introduced
- What each class or function is responsible for
- How to add [EXTENSION_SCENARIO] without modifying existing code

## Trade-offs

List the trade-offs of applying [DESIGN_PATTERN] here:
- Complexity added vs. flexibility gained
- Performance implications for [USAGE_PATTERN]
- When this pattern would become the wrong choice for [MODULE]

📝 Fill in the blanks

Replace these placeholders with your own content:

[EXISTING_MODULE]
[DESIGN_PATTERN]
[LANGUAGE]
[PASTE_CURRENT_CODE_HERE]
[CURRENT_PROBLEM]
[EXPECTED_CHANGE]
[TEAM_CONTEXT]
[EXTENSION_SCENARIO]
[USAGE_PATTERN]
[MODULE]

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.