# SOLID Quick Reference

## The Five Principles

| Letter | Principle | One-Liner |
|--------|-----------|-----------|
| S | Single Responsibility | One reason to change |
| O | Open/Closed | Extend, don't modify |
| L | Liskov Substitution | Subtypes replace base types |
| I | Interface Segregation | Small, focused interfaces |
| D | Dependency Inversion | Depend on abstractions |

## SRP — How to Split

| Signal | Action |
|--------|--------|
| "And" in class description | Split by responsibility |
| Multiple axes of change | Separate modules |
| Unrelated tests | Different concerns |

## OCP — Extension Patterns

| Pattern | Use When |
|---------|----------|
| Strategy | Pluggable algorithms |
| Template Method | Skeleton with hooks |
| Plugin/Registry | Runtime-extensible |

## LSP — Substitution Checklist

- [ ] Subtype honors base type's contract
- [ ] No stronger preconditions
- [ ] No weaker postconditions
- [ ] No surprising side effects

## ISP — Interface Design

| Bad | Good |
|-----|------|
| One big interface | Multiple small interfaces |
| Implementers add no-ops | Clients depend only on what they use |
| God interface | Role-specific interfaces |

## DIP — Dependency Direction

```
High-level ──depends on──> Abstraction <──implements── Low-level
```

Inject abstractions via constructor; avoid `new` for collaborators.
