dallbit Prompt & Skill

Design Pattern-based Optimization

Maximizes code scalability and maintainability by applying specific design patterns.

Prompt Template

The more specific your inputs, the higher the quality of the output.

{{design_pattern}}
{{source_code}}

You are a software design pattern expert. Refactor the provided code by applying the Strategy Pattern pattern. ### Source Code if(type === 'A') { ... } else if(type === 'B') { ... } ### Requirements 1. **Justification**: Explain technically why this pattern is suitable for this specific context. 2. **Structure Comparison**: Provide a before-and-after comparison of the code structure. 3. **Scalability**: Specify how the pattern makes future extensions easier. Example: Applying the Strategy pattern to logic with many if-else branches to easily add new policies.