Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions _rules/0105.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
rule_id: 0105
rule_category: general
title: Use design patterns to communicate intent
severity: 2
---
[Design patterns](https://en.wikipedia.org/wiki/Software_design_pattern) are proven, named solutions to recurring design problems. Using them lets you communicate the structure and intent of your code in a single recognizable term: *Repository*, *Factory*, *Strategy*, *Observer*, *Decorator*, and so on.

When you refactor a complex piece of code into a well-known pattern:
- Other developers immediately understand the structure without having to reverse-engineer it.
- The code gains a shared vocabulary that transcends the codebase.
- It becomes easier to reason about responsibilities and extension points.

> [!TIP]
> If you cannot assign a single design pattern to a class, it may be doing more than one thing. Consider splitting it up.

> [!TIP]
> Don't force a pattern onto code that doesn't need it — a pattern is a tool, not a goal. Prefer simplicity when the problem doesn't warrant the extra structure.