Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

21
  • 5
    What is the principal difference between passing tens of parameters hidden in a struct and passing them explicitly? Commented Jul 13, 2017 at 8:03
  • 21
    @Ruslan Cohesion. Commented Jul 13, 2017 at 8:26
  • 9
    And you are more likely to refactor the function into smaller functions, since you can just pass along one parameter to the sub-functions instead of tens of parameters. And less risk of mixing up the parameters if you use positional arguments. Commented Jul 13, 2017 at 12:20
  • 8
    That's fine, but you have to ensure coherence in the Structs - make sure that the parameters grouped into a Struct are 'related'. You might use more than one Struct under some circumstances. Commented Jul 13, 2017 at 12:22
  • 8
    @abuzittingillifirca You do not get cohesion automatically. If the only justification for putting parameters in a struct is to pass them to a particular function, then the cohesion is probably illusory. Commented Jul 13, 2017 at 16:17