Linux variable naming rules

Source: Internet
Author: User

The recommended naming rules for Linux are as follows.

(1) The variable name must be meaningful and accurate. For example, a variable is used to save the number of books. It can be named number_of_book or num_of_book. I is not recommended because it is meaningless. We do not recommend using number or book because the meaning is inaccurate.

(2) case-insensitive mixing is not recommended. For example, define a count variable, int nCount; this is a good variable name in Windows. The first letter of nCount n indicates that the type of the variable is int. However, in Linux, it is not recommended to mix uppercase and lowercase letters. Generally, identifiers only consist of lower-case letters, numbers, and underscores.

(3) Use a short variable name whenever possible without meaning. For example, a variable is used to temporarily store a Count value. It is better to name the variable tmp_count than this_is_a_temperary_counter.

(4) The type of the variable is not represented by the Hungarian name. For example, int nCount; n is used to indicate the type of the variable. It is not recommended to name the variable in Linux.

(5) The function name should start with a verb because the function is a group of statement blocks with specific functions. For example, if a function is used to obtain the value of an external input, it can be named get_input_number.

(6) Avoid using global variables whenever possible.

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.