Introduce a design pattern
Identify the right design pattern (Strategy, Factory, Observer, etc.) for a structural code problem and apply it with a before/after comparison.
Preview
Copy prompt
The following code has this structural problem: [Describe the problem, e.g. tight coupling, repeated conditionals, hard-to-test dependencies]: [Paste code]. Identify the most appropriate design pattern from the GoF catalogue or architectural patterns such as Strategy, Observer, Factory, Repository, or Decorator. Show a before-and-after refactor that applies the pattern and explain why this pattern is the right fit for this specific problem.
More
Refactoring
Prompts
