4 ms·
>I don’t recommend a large number of parameters in any paradigm. Your case is a good example. Sure, I understand that too many parameters is to be avoided and
by jasode 6y ago
>I don’t recommend a large number of parameters in any paradigm. Your case is a good example.
Sure, I understand that too many parameters is to be avoided and can point to some underlying poor architecture design. However, _if_ there's irreducible complexity that calls for 5+ parameters to minimally specify behavior, what are the better syntax options than named parameters?
If you say "create a struct with members and pass the struct instead", then you're just shifting the "named params" to the "struct member names".
This causes the extra verbose syntax of defining one-time-use struct variables to pass as a function argument. In contrast, named parameters in the function can act as "anonymous unnamed struct" which is cleaner.
Using structs as function parameters is more useful when the structs can also be re-used elsewhere in multiple places (e.g. 3d points {x, y, z}).