Code Smell 10 - Too Many Arguments
Objects or Functions need too many arguments to work
Find cohesive relations among arguments
Create a "context".
Consider using a Method Object Pattern.
Avoid "basic" Types: strings, arrays, integers, etc. Think on objects.
- Operations in real world needing not cohesive collaborators.
Most linters warn when the arguments list is too large.
Relate arguments and group them. Always favor real world mappings. Find in real world how to group the arguments in cohesive objects.
If a function gets too many arguments, some of them might be related to the class construction. This is a design smell too.
This article is part of the CodeSmell Series.