Perl Best Practices (excerpt)---03

Source: Internet
Author: User

Chapter III: Naming conventions 0--three.

use grammar templates when composing identifiers.

The l variable is named after the noun, without or adding more than one adjective:

variable→[adjective _]* noun

L Hash and array:

look-variable→[adjective _]* noun preposition 0 ii.

Name the Boolean value based on the relevant test. 0 Wu.

The variable that stores the reference is marked with the _ref suffix. 0 land.

The array is named after the plural, and the hash is named in the singular.

Perl has the formatting tools available: Perltidy.

Website: http://perltidy.sourceforge.net 0.

The following underline separates the words in the multi-word identifier. 0 ba.

distinguishes between different program components in case of casing.

The names of the L subroutines, methods, variables, tagged arguments are all lowercase.

L Package and class names use mixed casing.

The L constants use uppercase. 0 nine.

The prefix is used as an abbreviation.

Note: When you use the prefix as an abbreviation for an identifier, it is acceptable to keep the last consonant (usually also indispensable), especially if the consonant is a plural suffix. 0 three 0.

abbreviated only when the meaning is clear. 0 three.

avoid using vague words in the name.

We refuse to use "last". For example, a variable named $last_record might refer to a recently processed record (which should be called $prev_record at this time), but it may also refer to the final record in the list (which should be called $final_record).

Other common words that should be avoided are as follows:

L "Left" (direction vs. remainder)

L "Right" (the other Side vs.) Correct vs. Rights

L "no" (negative vs.) Abbreviation for numbers)

L "Contract" (Zoom Out vs.) Contract

L "Record" (Best score vs. DataSet vs.) Record

L "Second" (Second vs.) Time unit)

L "Bases" (several bases vs. Several foundations) 0 three.

The subroutine for internal use is underlined at the beginning.

We refuse to use "last". For example, a variable named $last_record might refer to a recently processed record (which should be called $prev_record at this time), but it may also refer to the final record in the list (which should be called $final_record).

Other common words that should be avoided are as follows:

L "Left" (direction vs. remainder)

L "Right" (the other Side vs.) Correct vs. Rights

L "no" (negative vs.) Abbreviation for numbers)

L "Contract" (Zoom Out vs.) Contract

L "Record" (Best score vs. DataSet vs.) Record

L "Second" (Second vs.) Time unit)

L "Bases" (several bases vs. Several foundations)

Perl Best Practices (excerpt)---03

Related Article

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.