# Switch Statements

> Complex switch statements that should be replaced with polymorphism.

- **Category**: Code Smells
- **Subcategory**: oo-abusers
- **Canonical URL**: https://designpattern.fyi/code_smells/switch-statements/

---

## Description
'**Intent**: Identify switch statements that select behavior based on type or properties, which often indicate missing polymorphism.

**Context**: You have complex switch or if-else chains that select behavior based on object types or properties. Adding new types requires modifying existing code.

**Solution**: Replace conditionals with polymorphism. Use the Strategy pattern or create subclasses with overridden methods.'



## Use Cases
Use when switch statements select behavior based on type and new types are frequently added.









---
**Reference**: [Original Source](https://refactoring.guru/smells/switch-statements)

