Javascript-What naming conventions do you like to use?

Source: Internet
Author: User
{Code ...} the source code of the facebook homepage I pulled out a few days ago is almost underlined, and WordPress uses underline. I also like to use underline when writing PHP, however, sometimes the hump is "professional ". While Javascript is preferred when writing. What do you like to use...
$userName = getUserNameById( 123 );$user_name = get_username_by_id( 123 );

The source code of the facebook homepage I pulled out a few days ago is almost underlined, and WordPress uses underline. I also like to use underline when writing PHP, however, sometimes the hump is "professional ".

While Javascript is preferred when writing.

What naming conventions do you like to use?

Link: Facebook PHP Source Code from August 2007

Reply content:
$userName = getUserNameById( 123 );$user_name = get_username_by_id( 123 );

The source code of the facebook homepage I pulled out a few days ago is almost underlined, and WordPress uses underline. I also like to use underline when writing PHP, however, sometimes the hump is "professional ".

While Javascript is preferred when writing.

What naming conventions do you like to use?

Link: Facebook PHP Source Code from August 2007

Java/js programming is often used in the hump mode. Database names, table names, fields, and Web parameters in databases are often connected by underscores, while CSS and command line parameters are often connected by horizontal bars.

In PHP, classes and objects are used to the camper method, and underlines are used to global variables and functions. However, if one of the tools and frameworks I use is named, I will try to stay consistent with him, or be local (for example, in a function, a large segment clearly distinguishes other parts of the Code ).

In particular, I like to use abbreviations and alignment (not just indent alignment, equal sign, colon, comma, or even end alignment, or display regularity). Many people disagree with this, but I like this.

It is recommended to follow the PSR-1:

Https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md

It is very detailed, and some popular libraries are currently used.

Camper "professional"You are not confident in this statement.

Most of the time, the project itself has standard requirements, and the individual is used to underline (the first half is the focus)

  • The Hump is not as readable as an underline, especially when the variable name contains all uppercase abbreviations.
  • What kind of problems should we solve when we use the hump, suchtestHttpServer TestHttpServer testHTTPServer TestHTTPServer, Self-writing is easy to be inconsistent, and team collaboration increases the memory burden.
  • A good IDE can help, but a good IDE can also automatically complete, so the underline will not increase the burden on your fingers, and the only advantage of camper is a little more convenient than the underline.

Python life style:

Http://zh-google-styleguide.readthedocs.org/en/latest/google-python-styleguide/python_style_rules/#id14

Specific naming rules:

module_name, package_name, ClassName, method_name, ExceptionName, function_name, GLOBAL_VAR_NAME, instance_var_name, function_parameter_name, local_var_name.

I personally like it, but my English is poor. I often use Google translation when I know what it means. It is estimated that there will be many jokes when the source code is released.

I don't like to use so many underlines. If you are in a good mood someday, you can use "camps". If you are in a bad mood, you can use case-insensitive words.

There are various methods, which are usedgetNameThis kind of hump type, however, is used only for the hump, sometimes it is not enough, such as a long variable namearrayData_or_mapDataWhen using other symbols such as underscores to separate different meanings, it may be more obvious, but the style may be different, but it is still practical.

I used to use underscores (_) as the first letter._getSystemDate

Different codes and products use different code styles. Java uses the prompts of Eclipse for naming. C ++ uses Hungary for naming and Linux for naming.

Php is better.

You can see how many libraries in C ++ use the naming rules of the standard library. Such as MFC, QT, and FLTK.

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.