Reputation: 23044
If you are writing a function for doing something and this function needs a lot of input(Parameters), so should I make a structure, class or whatever... to pass those parameters or not?
In other words, what's the recommended count of parameters that we should not exceed and use structure or object from class instead?
Upvotes: 1
Views: 271
Reputation: 499362
For readability you should indeed create a parameter object - it is a well known refactoring.
This is something you see in several places in the BCL itself - the Process
class can take a ProcessStartInfo
parameter object.
Some people think that 7 should be the most number of parameters, others say 3. You need to agree with your team on this. If working alone, look at increasing readability.
Upvotes: 3