Last Revision — April 19, 2022
2 Min Read
---
Bloaters
Measured Smells
Within a Class
- Long Method (co-exist)
- Message Chain (co-exist)
- Large Class (causes)
- Flag Arguments (caused)
- Temporary Field (caused)
- Global Data (antagonistic)
Martin Fowler in book (1999): "Refactoring: Improving the Design of Existing Code"
This is another code smell at the same abstraction level as Long Method which usually occurs when three, four, or more parameters are given as input for a single method. Basically, the longer the parameter list, the harder it is to understand.
In an attempt to generalize a routine with multiple variations, a developer could have passed too many parameters at one point. Another causation could be due to ignorance of the object relationship between other objects, and thus, instead, calling in all the entities via parameters [1].
Usage of a method with many parameters requires more knowledge to use it.
The input value is highly inconsistent, which creates too much variety in what might happen throughout the execution.
When there are too many parameters, most likely, the method tries to do too many things or has too many reasons to change.
def foo(author: str, commit_id: str, files: List[str], sha_id: str, time: str):
...
author, commit_id, files, sha_id, time = get_last_commit()
foo(author, commit_id, files, sha_id, time)
@dataclass(frozen=True)
class Commit:
author: str
commit_id: str
files: List[str]
sha_id: str
time: str
def foo(self):
...
commit = Commit(**get_last_commit())
commit.foo()