19. Number of function parameters (use the structure if there are more parameters)

Source: Internet
Author: User

-----------------

The number of function parameters should not be too large. Generally, about 6 parameters can be used. Many function parameters will allow readingCodePeople look dizzy at a glance, and it is not conducive to maintenance. If there are many parameters, use the structure to pass the parameters. This is conducive to Data encapsulation andProgramConciseness.

It is also helpful for users who use functions, because if you have a large number of functions, such as 12, the caller can easily make a mistake in the order and number of parameters, and use the structure struct to pass parameters, you can ignore the order of parameters.

Moreover, functions can be easily modified. If you need to add parameters to a function and do not need to change the function interface, you only need to change the structure and internal processing of the function. For programs that call the function, this action is transparent.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.