Don't perform more than requested.
TL;DR: Unless you need atomicity, don't perform more than one task.
- Coupling
- Single Responsibility Principle violation
- Readability
- Low Cohesion
- Testability
- Break the function
def fetch_and_display_personnel():
data = # ...
for person in data:
print(person)def fetch_personnel():
return # ...
def display_personnel(data):
for person in data:
print(person)Functions including "and" are candidates. However, we need to check them carefully since there might be false positives.
- Bloaters
[x] Beginner
We should avoid doing more than needed, and our functions should be both minimal and atomic.
What exactly is a name - Part II Rehab
This smell was inspired by
If it takes more than a sentence to explain what you are doing, itβs almost always a sign that what you are doing is too complicated.
Sam Altman
Software Engineering Great Quotes
This article is part of the CodeSmell Series.
