Number of parameters in a function

Generally we do not care about the number of parameters we pass in a function and even various technologies allow programmer to pass any number of parameters.

But ideally a programmer should set a limit to, how much number of parameters can be passed in a function. And in all our work we set this limit to 6 or 7. As If we are passing so many parameters, it means we are not making it clear, what the function is doing and what kind of parameter it is taking.

Again, there could be a requirement that we need to pass more than 7 parameters in a function. In those cases, programmer should bundle those parameters in an object (Class/structure) and then should only pass that object to function. And we should only bundle logically related parameters.

Tags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*