Reasons to use less global variables

Source: Internet
Author: User

Collected several reasons for less global variables, welcome to add ~

The first, the resource, the global variable, is before the program runs, there is.
Second, if the program is large, it is possible to define the same name, which is easy to mistake.
Thirdly, local variables can be substituted for all variables.
Four, the global variable is many, and other functions integration, inconvenient.
The global variable causes some functions to be non-reentrant. (non-reentrant means that when the program runs, it suddenly goes somewhere else to run, and then goes back to this place to run, and the run error occurs.) The meaning is simple, is a global variable, when a program runs, changes its value, and then suddenly break to another place, and then change its value, and then go back to the original place to run, there is an error, this is not re-entry. )
Six, the global variable destroys the program structure: for example, give you a function interface, you go to fill, but you have to use global variables, so you need to add your global variables in the main program, therefore, the program framework, there has been a little change.

Reasons to use less global variables

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.