Skip to content

Commit f44385e

Browse files
Add Anti-Patterns section explaining discouraged design patterns
1 parent 8c63fd0 commit f44385e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,27 @@ You can also run `flake8` or `pytest` commands manually. Examples can be found i
119119
## Contributing via issue triage [![Open Source Helpers](https://www.codetriage.com/faif/python-patterns/badges/users.svg)](https://www.codetriage.com/faif/python-patterns)
120120

121121
You can triage issues and pull requests which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to python-patterns on CodeTriage](https://www.codetriage.com/faif/python-patterns).
122+
123+
124+
## 🚫 Anti-Patterns
125+
126+
This section lists some common design patterns that are **not recommended** in Python and explains why.
127+
128+
### 🧱 Singleton
129+
**Why not:**
130+
- Python modules are already singletons — every module is imported only once.
131+
- Explicit singleton classes add unnecessary complexity.
132+
- Better alternatives: use module-level variables or dependency injection.
133+
134+
### 🌀 God Object
135+
**Why not:**
136+
- Centralizes too much logic in a single class.
137+
- Makes code harder to test and maintain.
138+
- Better alternative: split functionality into smaller, cohesive classes.
139+
140+
### 🔁 Inheritance overuse
141+
**Why not:**
142+
- Deep inheritance trees make code brittle.
143+
- Prefer composition and delegation.
144+
- “Favor composition over inheritance.”
145+

0 commit comments

Comments
 (0)